P
PopatoChisp
Guest
Hi, I have a little problem with changing the sprite when the object moves and changes direction.
the sprite changes to the walk sprite when moving and back to the static sprite when standing and also changes to the sprite for the right direction.
But it sometimes slides a bit or switches to the walk sprite for a moment then back to the static one.
It's controlled trough a mouse click
That's the code I used in the Player objekt for that
and
And that's the code I used on the player object to switch sprites:
I also have piece of code in the MouseClick object which makes it transparent when it comes in contact with the player object.
I put the origin in the static and walk sprites on the same spot, which helped a bit to reduce the sliding, but hasn't solved the problem completly. I could live with the static sprite sliding slightly 8even if I would love to remove that too), but the biggest problem is the sudden changing to the walk sprite and then back to the static sprite.
the sprite changes to the walk sprite when moving and back to the static sprite when standing and also changes to the sprite for the right direction.
But it sometimes slides a bit or switches to the walk sprite for a moment then back to the static one.
It's controlled trough a mouse click
That's the code I used in the Player objekt for that
Code:
if(instance_exists(obj_MouseClick)){
mouseDistance = point_distance(x ,y, obj_MouseClick.x, obj_MouseClick.y);
move_towards_point(obj_MouseClick.x,obj_MouseClick.y, min(9, mouseDistance));
}
Code:
if(!instance_exists(obj_MouseClick)){
instance_create(mouse_x,mouse_y,obj_MouseClick);
}
Code:
if(instance_exists(obj_MouseClick)){
if obj_Playertest.x < obj_MouseClick.x {
if image_speed > 0 {
sprite_index = Clara_walk_right;
}}}
if(instance_exists(obj_MouseClick)){
if obj_Playertest.x > obj_MouseClick.x {
if image_speed > 0 {
sprite_index = Clara_walk_left;
}}}
if(place_meeting(x,y,obj_MouseClick)){
if sprite_index = Clara_walk_left{
sprite_index = Clara_static_left
}}
if(place_meeting(x,y,obj_MouseClick)){
if sprite_index = Clara_walk_right{
sprite_index = Clara_static_right
}}
Code:
if(place_meeting(x,y,obj_Playertest)){
image_alpha = 0;
} else {
image_alpha = 1;
}