Ashish

How player(sprite) in the phaser will opposite or reverse while going left and right?

Recommended Posts

I am developing a game where my player has to look to see forward when I am pressing right arrow key. But how can I make it look reverse after pressing left arrow? I can create a sprite of reverse look but how can load that while pressing left and at the same time forward player should be destroyed?

Share this post


Link to post
Share on other sites

You need create a new variable lastDirection.
Then how this be execute 60 times per second in the update function, you need save each click and save the last direction.
Finally you should compare if the last direction, was left or right and use one animation o another. (Previously created)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.