安装 Steam
登录
|
语言
繁體中文(繁体中文)
日本語(日语)
한국어(韩语)
ไทย(泰语)
български(保加利亚语)
Čeština(捷克语)
Dansk(丹麦语)
Deutsch(德语)
English(英语)
Español-España(西班牙语 - 西班牙)
Español - Latinoamérica(西班牙语 - 拉丁美洲)
Ελληνικά(希腊语)
Français(法语)
Italiano(意大利语)
Bahasa Indonesia(印度尼西亚语)
Magyar(匈牙利语)
Nederlands(荷兰语)
Norsk(挪威语)
Polski(波兰语)
Português(葡萄牙语 - 葡萄牙)
Português-Brasil(葡萄牙语 - 巴西)
Română(罗马尼亚语)
Русский(俄语)
Suomi(芬兰语)
Svenska(瑞典语)
Türkçe(土耳其语)
Tiếng Việt(越南语)
Українська(乌克兰语)
报告翻译问题
Constant Description
vk_nokey keycode representing that no key is pressed
vk_anykey keycode representing that any key is pressed
vk_left keycode for left arrow key
vk_right keycode for right arrow key
vk_up keycode for up arrow key
vk_down keycode for down arrow key
vk_enter enter key
vk_escape escape key
vk_space space key
vk_shift either of the shift keys
vk_control either of the control keys
vk_alt alt key
vk_backspace backspace key
vk_tab tab key
vk_home home key
vk_end end key
vk_delete delete key
vk_insert insert key
vk_pageup pageup key
vk_pagedown pagedown key
vk_pause pause/break key
vk_printscreen printscreen/sysrq key
vk_f1 ... vk_f12 keycode for the function keys F1 to F12
vk_numpad0 ... vk_numpad9 number keys on the numeric keypad
vk_multiply multiply key on the numeric keypad
vk_divide divide key on the numeric keypad
vk_add key on the numeric keypad
vk_subtract subtract key on the numeric keypad
vk_decimal decimal dot keys on the numeric keypad
Constant Description
vk_lshift left shift key
vk_lcontrol left control key
vk_lalt left alt key
vk_rshift right shift key
vk_rcontrol right control key
vk_ralt right alt key
http://docs.yoyogames.com/source/dadiospice/002_reference/mouse,%20keyboard%20and%20other%20controls/keyboard%20input/
if keyboard_check(vk_shift)
{
// welcome to GameMaker
}
What I'm trying to ask is this. I have created the following keyboard_check(vk_shift) command to create my instance, and as I mentioned, it works great if my player is standing still. If I move forward then stop and press shift, the instance gets created at the proper x,y coordinate. If I rotate then stop and press shift, the instance gets created at the proper x,y coordinate.
If I press shift and then move or rotate during the 5 second animation, the instance does not follow my player movement or direction.
my_beam = instance_create(x + lengthdir_x(25, 2 + image_angle), y + lengthdir_y(25, 2 + image_angle), obj_mining_beam);
my_beam.direction = image_angle;
my_beam.image_angle = image_angle;
my_beam.speed = 0;
audio_play_sound(snd_mining_beam,0,0);
So what I'm asking, in order to have my instance follow the player movement and rotation, I have 2 questions:
1) Do I need to create a step or end step event as well? This seems like an obvious "yes" but I'm not sure.
2) If yes, do I also need to add " if keyboard_check(vk_shift) " {execute code} within the step event I create?
This all seems really similar to my create bullet event except with the bullet instance, I did not need to create and end step because the bullet just speeds away at a speed of 25.
I can't do the same for my beam, because the speed, angle, etc..are unknown or may change because I move or rotate my player.
//==== Create Bullet
bullet = instance_create(x + lengthdir_x(20, 0+image_angle), y + lengthdir_y(20, 0+image_angle),obj_9mm_bullet);
bullet.direction = image_angle;
bullet.image_angle = image_angle;
bullet.speed = 25;
audio_play_sound(snd_9mm_bullet,0,0);
At this point all objects in their needed position and don't move.
What is your animation? Sounds like you have some movings that is not actually movings, but sprites animation. It affect object's drawing, but not affect it ngle and coordinates, and your code can't work fine.
Imagine this, you have a gun and a bullet using similar code to what I posted above. Chances are, typically your bullet sprite is just 1 frame.
Now copy and paste the frame and add a glow effect to your bullet in the 2nd frame. Now your bullet is a 2 frame animation. Nothing else changes other than your bullet speeds across the screen with a glow effect.
Using my code for the beam, if I change the speed = 25. My mining tool will shoot the beam across the screen just like a bullet, but that's not what I want. I just want it to redraw the beam in a stationary position every frame to mirror the lengthdir coordinates that I've entered.
Based on my current situation, it wouldn't matter if I changed my mining beam to a 1 frame fixed picture. It still wouldn't follow my player. So I think the fact that it's currently animated is irrelevant.
I don't know the exact code to write for the alarm. My instance now draws twice, once every 2 seconds. Where as I want it to draw every frame which I thought would be = to room speed but I don't know why there's a 2 second delay in the redraw. I rewrote some things as follows:
{
my_beam = instance_create(x + lengthdir_x(25, 2 + image_angle), y + lengthdir_y(25, 2 + image_angle), obj_mining_beam);
my_beam.direction = image_angle;
my_beam.image_angle = image_angle;
my_beam.speed = 0;
audio_play_sound(snd_mining_beam,0,0);
if (alarm [0] = -1) alarm = room_speed
}
my_beam.y = (y + lengthdir_y(25, 2 + image_angle));
my_beam.direction = image_angle;
my_beam.image_angle = image_angle;
my_beam.speed = 0;
Well, I finally figured this out. The end step that I thought I needed kept crashing because it would look for my instance (which didn't exist until I pressed the shift key).
Turns out I stumbled across this "if instance_exists" function which did the trick.
if instance_exists(obj_mining_beam)
{
my_beam.x = (x + lengthdir_x(25, 2 + image_angle));
my_beam.y = (y + lengthdir_y(25, 2 + image_angle));
my_beam.direction = image_angle;
my_beam.image_angle = image_angle;
my_beam.speed = 0;
}