X
Xavion
Guest
please see my latest reply for the issue.
Hello, I've been having some problems in my platformer trying to get my crouching and rising animations to play. once I press down ("S" in this case) I'm trying to have my character play a crouch animation, then once the player has completely finished the crouch animation they will pause in that state until the player isn't holding down anymore, in which case the player will start playing a rise animation, and once the player finishes the rise animation they will go back to there regular idle animation. I'm not sure how to set up the crouching part as I stated earlier, but even when I just try to play the crouch animation it just makes my character's image speed and index become 0. I actually figured out the rising part, the animation part of it just doesn't play though.
Here's the create event:
Here's the step event:
Alarm 0
Alarm1
Alarm2
Alarm 3
Alarm 4
It's not necessary but if anyone also knows how to change the mask of the player depending on the crouch and rise sub images that would be great as well. Thanks!
Here's the create event:
Code:
///Initialize check
grav = 0.8;
hsp = 0;
vsp = 0;
jumpspeed = 25;
movespeed = 4;
rotating = false;
can_walk = false;
start_walk = true;
grounded = true;
crouching = false;
rising = false;
Code:
///Actions and Animations
///////Get the Player's input////////
if crouching = false and rising = false
{
key_right = keyboard_check(ord("D"));
key_left = -keyboard_check(ord("A"));
}
if grounded = true and crouching = false and rising = false
{
key_jump = keyboard_check_pressed(ord("J"));
}
if grounded = true
{
crouching = keyboard_check(ord("S"));
}
///////React to inputs/////////
if crouching = true or rising = true
{
hsp = 0
}
move = key_left + key_right;
if crouching = false and rising = false
{
hsp = move * movespeed;
}
if (vsp < 25) vsp += grav;
if (place_meeting(x, y+1, obj_wall))
{
grounded = true
vsp = key_jump * -jumpspeed
}
else
{
grounded = false
}
///////Horizontal Collision///////
if (place_meeting(x+hsp,y,obj_wall))
{
while(!place_meeting(x+sign(hsp),y,obj_wall))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;
////////Vertical Collision/////////
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y += sign(vsp);
}
vsp = 0;
}
y += vsp;
/////////////////Animation/////////////////
image_speed = 1/4;
if grounded = true
{
if crouching = true
image_index = spr_player_crouch;
}
if grounded = true && crouching = false
if ( keyboard_check(ord("A")) and image_xscale = 1 && !can_walk && !rotating )
{
alarm[0]= 10; // This alarm is for rotating animation
sprite_index = spr_player_rotate;
image_xscale = -1;
image_index = 0
rotating = true;
}
else
if ( keyboard_check(ord("D")) and image_xscale = -1 && !can_walk && !rotating )
{
alarm[0]= 10; // This alarm is for rotating animation
sprite_index = spr_player_rotate;
image_xscale = 1;
image_index = 0
rotating = true;
}
//Idle Animation Check
if ((keyboard_check_released(ord("D")) || keyboard_check_released(ord("A"))) or (movespeed = 0) && !rotating )
{
can_walk = false
sprite_index = spr_player_idle;
start_walk = true
}
//Walk check
if ( can_walk )
or ( keyboard_check(ord("D")) and image_xscale = 1 and sprite_index =! spr_player_rotate)
or ( keyboard_check(ord("A")) and image_xscale = -1 and sprite_index =! spr_player_rotate)
{
sprite_index = spr_player_walk; // your walking sprite here
}
//Start Walk
if ( keyboard_check_pressed(ord("A")) and image_xscale = -1 and start_walk = true && !can_walk && !rotating)
{
alarm[2]= 10; // This alarm is for walk start animation
sprite_index = spr_player_walk_start;
image_xscale = -1;
image_index = 0
image_speed = 1/5
}
else
if ( keyboard_check_pressed(ord("D")) and image_xscale = 1 and start_walk = true && !can_walk && !rotating)
{
alarm[2]= 10; // This alarm is for walk start animation
sprite_index = spr_player_walk_start;
image_xscale = 1;
image_index = 0
image_speed = 1/5;
}
//Crouching
if keyboard_check(ord("S")) and crouching = true
{
image_index = spr_player_crouch
}
//Rising
if (keyboard_check_released(ord("S"))) and grounded = true
{
rising = true
image_index = spr_player_rise
alarm[4]= 15;
}
Code:
///Variable Initializer
rotating = false;
can_walk = true;
alarm[1]= 1;
Code:
///Idle Animation Check
if (hsp = 0)
can_walk = false;
sprite_index = spr_player_idle;
Code:
start_walk = false;
image_index = 0
{
sprite_index = spr_player_walk;
}
alarm[3]= 1;
Code:
sprite_index = spr_player_idle;
Code:
rising = false
Last edited by a moderator: