Creating projectiles
Now we'll create the projectile
class. It will have a sprite that's pulled from the spritesheet, and it will move from left to right at a fixed velocity.
Creating the class
To start, make a new class in the source directory named Projectile
. Here it is for reference:
package; class TestSprite2 extends FlxSprite { public function new() { super(); } }
Adding imports
Next, add the imports:
import flixel.util.loaders.TexturePackerData; import flixel.FlxSprite;
Creating variables
Now add the variables we'll be using:
private var texturePackerData:TexturePackerData; private var speed:Float = 2000;
The speed
value will be used to determine the velocity of the projectile.
Displaying the sprite and setting the velocity
After the super call in ...
Get Haxe Game Development Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.