My object will move to a position where ever the mouse clicked or on touched(in mobiles). There are no arrows like right, left, top, bottom. Also there is no use of any keyboard buttons. Only touch/click is there.
I added animation when it’s moving. I also want to flip it horizontally when it is moving towards right direction. And if it moves left, i want to flip horizontally again.
Any help would be really appreciated.
This helped me in drawing line from object to where ever we click on the scene. I made some changes to hide the line after the object reaches the destination. But if the object is moving along the path, the line behind the object should not show.
Sorry, I don’t have time to help you with the implementation right now.
The idea in the example is that you have 2 objects, an invisible object move on the path and rotate and the actual sprite object follow the invisible object and you check the angle of the invisible and change the animation and flip the sprite according to the angle of the invisible. This is because you don’t actually want to rotate the sprite, so in the example we rotate the invisible object instead…
For you it is maybe way too overcomplicated actually. If all you want to know if the sprite is moving left or right maybe more simple to check the X position of the destination of the path.
If destination X >= the Jerry.X() then flip Jerry right
If destination X <= the Jerry.X() then flip Jerry left
The expression to get destination X is:
Great, next time maybe let people know so nobody wasting their time trying to help you while you no longer looking for a solution.
If it was something tricky and not just your lack of experience it is also useful to share what was the obstacle you experienced so others can learn from it too.