K
KitKatarine
Guest
So, my problem is this:
I want to approach a tree, and I want the code to determine whether the tree is to the left or to the right, and with that, display the right chopping animation(left or right). I read that sprite_index can do this for me, but all it does is change the numerical value for sprite index and not the actual sprite. I did do sprite_assign, and THAT works, with the exception I cannot change back to my static player sprite again.
Create Event:
Essentially, create the variables countdown and countdown start.
Step Event:
Which, in short, /SHOULD/ change the sprites while I am cutting trees, but it actually does nothing. All it does is change the value of sprite_index (I know this through a draw event I wrote up)
However, when I use sprite_assign, it works up until I have to change it back.
Can anyone tell me what I'm doing wrong??
Note: sp_lumchop & sp_lumchopRight are both animated with several subimages, but I don't think this should matter too much.
I want to approach a tree, and I want the code to determine whether the tree is to the left or to the right, and with that, display the right chopping animation(left or right). I read that sprite_index can do this for me, but all it does is change the numerical value for sprite index and not the actual sprite. I did do sprite_assign, and THAT works, with the exception I cannot change back to my static player sprite again.
Create Event:
Code:
countdown = room_speed*10 // ten second timer
countdown_start = 0; // returns 1(true) or 0 (false)
Step Event:
Code:
var tree_nearest_id = instance_nearest(obj_player.x, obj_player.y, obj_tree);
if countdown_start = 1
{
countdown --
if countdown > 0 //&& countdown_start = 1
{
if tree_nearest_id.x > obj_player.x
{
with (obj_player)
{
sprite_index = sp_lumchopRight
}
}
else if tree_nearest_id.x <= obj_player.x
{
with(obj_player)
{
sprite_index = sp_lumchop
}
}
}
if countdown = 0
{
with (tree_nearest_id)
{
instance_change(obj_stump, true)
}
countdown = room_speed*10;
countdown_start = 0;
}
}
else if countdown_start = 0
{
with(obj_player)
{
sprite_index = sp_player
}
}
However, when I use sprite_assign, it works up until I have to change it back.
Can anyone tell me what I'm doing wrong??
Note: sp_lumchop & sp_lumchopRight are both animated with several subimages, but I don't think this should matter too much.