HaxeFlixel Logo HaxeFlixel Snippets
  • About
  • Tutorials
  • Back to HaxeFlixel.com
  • Basics
    • Screen
    • Adding
  • Objects
    • Alive
    • Health
  • Sprites
    • Making Sprites
    • Loading Sprites
    • Animation
    • Alpha
    • Color
    • Facing
    • Scale
    • Baked Rotations
  • Text
    • FlxText
    • FlxBitmapText
  • Movement
    • Velocity
    • Acceleration
    • MaxVelocity
    • Gravity
    • Jumping
    • Angle
    • Angular Velocity
    • Angular Acceleration
  • Groups
    • Basic Group
    • Typed Group
    • Recycling
  • Tiling
    • Tileblock
    • Tilemap
  • Overlap
    • Simple Overlap
    • Overlap Callbacks
  • Collision
    • 1-to-1 Collision
    • Immovable
    • Tilemap Collision
    • Moving Platforms
  • Camera
    • Flash
    • Fade
    • Shake
    • Follow
  • Input
    • Basics
    • Keyboard
    • Mouse
    • Button
  • Sound
    • FlxSound

Angle

You can set the angle of a FlxObject to rotate it. By default, angle is 0, which is to the right.

// sprite's angle will be set to 90 (down)
sprite.angle = 90;

Demonstration

Source

source/PlayState.hx

package;

import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;

class PlayState extends FlxState
{
    var sprite:FlxSprite;

    override public function create()
    {
        super.create();

        sprite = new FlxSprite("assets/arrow.png");
        sprite.screenCenter();
        add(sprite);
    }

    override public function update(elapsed:Float)
    {
        super.update(elapsed);

        sprite.angle += elapsed * 30;
    }
}
View Source on GitHub

See Also

  • Sprites/baked-rotations

Tags

movement
  1. Home
  2. Movement
  3. Angle
Powered By HaxeFlixel Logo HaxeFlixel