Created
October 15, 2013 02:07
-
-
Save videlais/6985493 to your computer and use it in GitHub Desktop.
ActionScript 3 Example 2 PlayState Version 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
/** | |
* ... | |
* @author Dan Cox | |
*/ | |
import org.flixel.*; | |
public class PlayState extends FlxState | |
{ | |
private var background:FlxSprite; | |
public function PlayState() | |
{ | |
background = new FlxSprite(); | |
background.makeGraphic(100, 100); | |
add(background); | |
} | |
override public function update():void | |
{ | |
super.update(); | |
if (FlxG.keys.W || FlxG.keys.UP) | |
{ | |
background.y -= 3; | |
} | |
else if (FlxG.keys.S || FlxG.keys.DOWN) | |
{ | |
background.y += 3; | |
} | |
else if (FlxG.keys.A || FlxG.keys.LEFT) | |
{ | |
background.x -= 3; | |
} | |
else if (FlxG.keys.D || FlxG.keys.RIGHT) | |
{ | |
background.x += 3; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment