Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PlayState.hx
- package;
- import flixel.FlxState;
- import flixel.FlxSprite;
- import flixel.FlxCamera;
- import flixel.FlxG;
- class PlayState extends FlxState
- {
- private var _playerrunner:Player;
- private var ground:FlxSprite;
- override public function create():Void
- {
- super.create();
- _playerrunner = new Player();
- add(_playerrunner);
- ground = new FlxSprite(0,100);
- ground.makeGraphic(1000,3,flixel.util.FlxColor.RED);
- ground.immovable = true;
- add(ground);
- add(_playerrunner);
- }
- override public function update(elapsed:Float):Void
- {
- super.update(elapsed);
- FlxG.collide(_playerrunner,ground);
- // FLxCamera.follow(_playerrunner);
- // FlxG.camera.zoom = 3;
- // FlxG.camera.width = Std.int(FlxG.camera.width / 3);
- // FlxG.camera.height = Std.int(FlxG.camera.height / 3);
- FlxG.camera.follow(_playerrunner);
- }
- }
- -----------------------------------
- Player.hx
- package;
- import flixel.FlxSprite;
- import flixel.FlxG;
- import flixel.math.FlxPoint;
- class Player extends FlxSprite
- {
- var playr:FlxSprite;
- public function new()
- {
- super(3,3);
- makeGraphic(10, 50, 0xCFCFCFCF);
- velocity.x = 100;
- // acceleration.x = 100;
- acceleration.y = 100;
- }
- override public function update(elapsed:Float):Void
- {
- super.update(elapsed);
- // if(x>400)
- // velocity.x = -100;
- // if(x<4)
- // velocity.x = 100;
- }
- }
Add Comment
Please, Sign In to add comment