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

Making Sprites

Use FlxSprite.makeGraphic() to create a FlxSprite of a solid color.

// sprite's graphic will be made into a 128px by 64px solid red rectangle
sprite.makeGraphic(128, 64, FlxColor.RED);

Demonstration

Source

source/PlayState.hx

package;

import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.util.FlxColor;

class PlayState extends FlxState
{
    override public function create()
    {
        super.create();

        var sprite = new FlxSprite();
        sprite.makeGraphic(128, 64, FlxColor.RED);
        sprite.screenCenter();
        add(sprite);
    }
}
View Source on GitHub

Tags

sprites graphics
  1. Home
  2. Sprites
  3. Making Sprites
Powered By HaxeFlixel Logo HaxeFlixel