Direction of a sprite

0 favourites
  • 10 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • Hello,

    How to know the direction of an object?

    I want to make a game where enemies move freely but I don't detect the direction of the sprite to change the animation

    anyone know how to do?

  • In Construct2, "direction" is called "angle." An angle of 0 means the sprite is moving to the right, and 180 means it is moving to the left, etc. You can use a sprite's "is between angles" event to detect its current angle/ direction.

  • thanks! but if the enemy moves in 4 directions?

    If the sprite goes in horizontal direction and rotates clockwise, the sprite will change the animation to go down or up but if the sprite walks in the vertical direction and rotate to the right will change the animation to walk to the right or left.

    How is that done?

    The sprite can be rotated at the same angle but depending on the direction that has the sprite animation can be different

    thanks!

  • You can always detect the sprite's angle of movement, so then it is just a matter of selecting the animation that goes with that angle. If you have four animations which you name left, right, up, down, and the sprite's angle is 180, then you set the animation "left" for the sprite. If the sprite's angle is 90, then you set the animation to "down" and so on.

  • Hello,

    I did what you say but the sprite does not rotate.

    I want that when it collides with the arrow sprite changing direction and animation but does not.only changes the direction not the animation. Sure you do something wrong..

    let the example

    dropbox.com/s/7u0fgjpzwwd3qz7/pac.capx

    Thanks!

  • Since your animations are just single frames, there may be easier ways to flip between the images. In fact, if the sprite has the bullet behavior, you can rotate the sprite image to the angle of movement. You don't do this with an event, but in the bullet behavior properties. Here is a demo capx. (Note, I created this with the latest release, v.92, that came out yesterday. So you need r92 to run it.)

    http://dl.dropbox.com/u/6109058/ChangeDirDemo.capx

  • Here is a modified demo, in which clicking the mouse changes the direction and image by 90 degrees.

    http://dl.dropbox.com/u/6109058/ChangeDirDemo2.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I made ??the changes you told me . He behavior fantasma al bullet change direction rotates the image but does not change to another animation simply rotates the principal image .Later, the game will have more complex animations

    dropbox.com/s/7u0fgjpzwwd3qz7/pac.capx

    thanks!

  • Maybe this thread will help you. There are two different versions -- the original one switches the animation frame based on the angle of the sprite and the second one switches the animation itself, not just the frame.

    Change Frames like Compass Sprite in 8dir

  • ok thanks! It has given me a great idea to pursue the enemy sprite to the player

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