R
RPC PRO
Guest
*Not native English speaker
Hi, im having troubles changing the sprite of my player while he shoots (sp_nr_shoot1).
1° problem:
The sprite doesnt finish and it change immediately to the "stand sprite (sp_nr_stand)", i need that the animation of the shoot sprite keeps playing till the end.
2° problem:
I need it to change while its in the air,to a second sprite ( sp_nr_shootair). I havent make it code yet, because i dont know how.
3° problem:
If need a third sprite change, while the player is running and shooting. Something like:
if (move!=0) while button 1 sprite_index = sp_nr_runshoot;
I think that i have the trouble in the //input part of the code, in the
button1 = keyboard_check_pressed(vk_space);
And in the //animation part:
if button1 sprite_index = sp_nr_shoot1;
Everything else works fine.
If someone can help me please.
Thanks a lot.
--------------------------------------------------------------------------------------------------------------------------------------------
Here is the code: its in the step event
//input ( IMPORTANT)
key_right = keyboard_check(vk_right) or keyboard_check(ord("D"));
key_left = -keyboard_check(vk_left) -keyboard_check(ord("A"));
key_jump = keyboard_check_pressed(vk_up) or keyboard_check(ord("W"));
button1 = keyboard_check_pressed(vk_space); // this is the shoot button
key_down = keyboard_check(ord("S"));
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 30) vsp += grav;
if (place_meeting(x,y+1,obj_muros_1))
{
if (key_jump) vsp = -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_muros_1))
{
yplus=0;
while (place_meeting(x+hsp,y-yplus,obj_muros_1) && yplus <= abs(1*hsp)) yplus +=1;
if place_meeting(x+hsp,y-yplus,obj_muros_1)
{
while(!place_meeting(x+sign(hsp),y,obj_muros_1))x += sign(hsp);
hsp = 0;
}
else
{
y -=yplus;
}
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_muros_1))
{
while(!place_meeting(x,y+sign(vsp),obj_muros_1))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//animation ( IMPORTANT)
if (move!=0) image_xscale = move;
if (place_meeting(x,y+1,obj_muros_1))
{
if (move!=0) sprite_index = sp_nr_run; else sprite_index = sp_nr_stand;
}
else
{
if (vsp < 0) sprite_index = sp_nr_jumpup; else sprite_index = sp_nr_jumpdown;
};
if button1 sprite_index = sp_nr_shoot1;
Hi, im having troubles changing the sprite of my player while he shoots (sp_nr_shoot1).
1° problem:
The sprite doesnt finish and it change immediately to the "stand sprite (sp_nr_stand)", i need that the animation of the shoot sprite keeps playing till the end.
2° problem:
I need it to change while its in the air,to a second sprite ( sp_nr_shootair). I havent make it code yet, because i dont know how.
3° problem:
If need a third sprite change, while the player is running and shooting. Something like:
if (move!=0) while button 1 sprite_index = sp_nr_runshoot;
I think that i have the trouble in the //input part of the code, in the
button1 = keyboard_check_pressed(vk_space);
And in the //animation part:
if button1 sprite_index = sp_nr_shoot1;
Everything else works fine.
If someone can help me please.
Thanks a lot.
--------------------------------------------------------------------------------------------------------------------------------------------
Here is the code: its in the step event
//input ( IMPORTANT)
key_right = keyboard_check(vk_right) or keyboard_check(ord("D"));
key_left = -keyboard_check(vk_left) -keyboard_check(ord("A"));
key_jump = keyboard_check_pressed(vk_up) or keyboard_check(ord("W"));
button1 = keyboard_check_pressed(vk_space); // this is the shoot button
key_down = keyboard_check(ord("S"));
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 30) vsp += grav;
if (place_meeting(x,y+1,obj_muros_1))
{
if (key_jump) vsp = -jumpspeed
}
//Horizontal Collision
if (place_meeting(x+hsp,y,obj_muros_1))
{
yplus=0;
while (place_meeting(x+hsp,y-yplus,obj_muros_1) && yplus <= abs(1*hsp)) yplus +=1;
if place_meeting(x+hsp,y-yplus,obj_muros_1)
{
while(!place_meeting(x+sign(hsp),y,obj_muros_1))x += sign(hsp);
hsp = 0;
}
else
{
y -=yplus;
}
}
x += hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,obj_muros_1))
{
while(!place_meeting(x,y+sign(vsp),obj_muros_1))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
//animation ( IMPORTANT)
if (move!=0) image_xscale = move;
if (place_meeting(x,y+1,obj_muros_1))
{
if (move!=0) sprite_index = sp_nr_run; else sprite_index = sp_nr_stand;
}
else
{
if (vsp < 0) sprite_index = sp_nr_jumpup; else sprite_index = sp_nr_jumpdown;
};
if button1 sprite_index = sp_nr_shoot1;