Is there any function which call whenever sprite position changes. Actually in my game I do certain tasks depending upon (player)sprite position. When we apply actions like MoveTo or JumpBy on player sprite, I can only get sprite position after action is complete, in its call back method. I want to access player sprite position while action is performing on player sprite. I want to override this method
Get sprite position while action(MoveTo, JumpBy) is performing on it.
(4 posts) (4 voices)-
Posted 2 years ago #
-
My initial thought is that you'll have to schedule a timer to call a method to check for position values. So you could call something that does the following:
x = mySprite.position.x; y=mySprite.position.y;Then do your decision process off those values. You'll need to play with the timer's duration between calls depending upon the speed of the action cause otherwise you could miss events due to less frequent checks. If this is a primary function of your game then it should be baked into your game loop.
Posted 2 years ago # -
I haven't tried it but can you override setPosition? I would think you should be able to then just store the value or do the logic there.
Posted 2 years ago # -
I have the same kind of issue. I want to detect collision of two sprite, such as bullet hit the target. The only the I can think of is get sprite position and detect it frequently. Is there any solutions?
Posted 2 years ago #
Reply
You must log in to post.