How do I get the direction of a moving sprite?

0 favourites
  • 6 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • I need to evaluate the current direction of a moving sprite, so that I can set the correct animation chosen from an 8-directional set of animations.

    I have searched the forum and the manual for help, but can't seem to find the info.

    I know it must be possible, its a very basic requirement.

    I have attached a capx of my test file.

    Also below is a snapshot of what I was trying to achieve using the "angle" expression before I realised it wasnt the right approach.

    Any help appreciated

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What you are looking for is the property MovingAngle. It's a property both of the Platform and 8Direction behaviors and you access it by looking inside behavior properties. For instance, if your avatar is called PlayerAvatar, the property would be PlayerAvatar.Platform.MovingAngle (or PlayerAvatar.8Direction.MovingAngle in case you're using this behavior).

    You can check a working example at the url below:

    http://www.gamesintheattic.com/examples/directions/

    Move the dog to all 8 directions using the arrows, the MovingAngle property is shown on the top left corner.

    Your code seems to be ok. However, I prefer to have an invisible object called player, which I control directly, and have another object, called avatarAnimations, which contains all animations, pinned to it.

  • OK that's great thank you.

    What is the benefit of pinning an invisible character to an animated sprite over just animating the sprite directly?

    Thanks again

  • I have just found the "direction" property in the gridmove function! My next step will be trying to get gridmove to work diagonally...

    For the benefit of anybody that needs to know how to do this in future, using the Grid_MoveTO function, I have shown the event below:

  • OK that's great thank you.

    What is the benefit of pinning an invisible character to an animated sprite over just animating the sprite directly?

    Thanks again

    To be honest, I can't remember why I started doing it, but it was related to an animation problem I had.

  • lol fair enough. i'll probably stumble across that issue one day... at least i'll know a workaround.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)