A
Amazing creature
Guest
when holding the left mouse button, the player will do a blowing ability that aims towards the mouse, the problem is that before blowing in the direction it's supposed to, it appears to the right of the player
obj_player
create:
step:
obj_blow
step:
obj_player
create:
Code:
changedir = true
// blow ability
canblow = true // if able to use the blow ability
blow_start = 0 // 1. preparing blow ani, 2. blow ani and usage
enum states
{
normal,
blowing,
}
current_state = states.normal;
// the only thing that changes when changing the states are the player sprites
step:
Code:
/// blow
// if you can blow
if canblow = true
{
if mouse_check_button(mb_left)
{
current_state = states.blowing
// aim blow sprite
changedir = false
// face right
if x < mouse_x
{
image_xscale = 1;
}
// face left
if x > mouse_x
{
image_xscale = -1;
}
// preparing blow animation
if blow_start = 0
{
sprite_index = spr_blowing0
blow_start = 1
}
// blowing
if blow_start = 2
{
sprite_index = spr_blowing1
// the blow
if !instance_exists(obj_blow)
{
instance_create(x,y,obj_blow)
}
}
}
}
// release or not holding blow
if mouse_check_button_released(mb_left)
{
current_state = states.normal
blow_start = 0;
changedir = true
if instance_exists(obj_blow)
{
with(obj_blow) instance_destroy();
}
}
step:
Code:
// image direction
dir = point_direction(obj_player.x,obj_player.y,mouse_x,mouse_y)
image_angle = dir
// on player's position
if obj_player.x < mouse_x{
x = obj_player.x//+15
y = obj_player.y//+15
} else {
x = obj_player.x//-15
y = obj_player.y//+15
}
Attachments
-
17.6 KB Views: 4
-
41.3 KB Views: 4