forked from AdamAtomic/flixel
-
Notifications
You must be signed in to change notification settings - Fork 17
Animated cursor
MarinMoulinier edited this page Apr 7, 2012
·
4 revisions
Do you want to create an animated cursor?
package co.cc.aberustudios.FlxUtils
{
import orgs.flixel.*;
[Embed(source="../../../../../media/graphics/gameCursor.png")] private var imgGameCursor:Class;
public class AnimatedCursor extends FlxSprite
{
public function AnimatedCursor()
{
super();
loadGraphic(imgGameCursor, true);
addAnimation("normal", [0, 1,etc], 5);
}
override public function update():void
{
super.update();
play("normal");
x = FlxG.mouse.x;
y = FlxG.mouse.y;
}
}
}
With this class you can! Customize the add animation, change embed and you’re ready! (the class goes inside a FlxUtils folder that’s inside an aberustudios folder that’s inside a cc folder that’s inside a co folder that’s inside the src folder) You can also set up an offset. To use the cursor, simply paste this in the state do you want to use it:
FlxG.showCursor();
This hides the cursor.
add(new AnimatedCursor());
This adds a new instance of our AnimatedCursor class.
And now you’re done!
Hope you like it!