Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MState extends FlxState
- {
- public var _image : FlxSprite;
- public var _title : FlxSprite;
- public var _playText : FlxText;
- public var _optionsText : FlxText;
- public var _quitText : FlxText;
- //public var _helpText : FlxText;
- public var currChoice : Int = 0;
- public var _dot : FlxSprite;
- public var _menubg : FlxSprite;
- override public function create():Void {
- _image = new FlxSprite(0, 0);
- _image.loadGraphic("assets/images/clockanim.png", true, 400, 400);
- _title = new FlxSprite(0, 50, "assets/images/menutitle.png");
- //dot is 20x20
- _playText = new FlxText(935, 400, 100);
- _playText.text = "PLAY";
- _playText.setFormat("assets/data/font.otf", 32, FlxColor.WHITE);
- _optionsText = new FlxText(935, 440, 100);
- _optionsText.text = "OPTIONS";
- _optionsText.setFormat("assets/data/font.otf", 32, FlxColor.WHITE);
- _quitText = new FlxText(935, 480, 100);
- _quitText.text = "QUIT";
- _quitText.setFormat("assets/data/font.otf", 32, FlxColor.WHITE);
- FlxSpriteUtil.screenCenter(_image, true, true);
- FlxSpriteUtil.screenCenter(_title, true, false);
- _dot = new FlxSprite(500, 560, "assets/images/dot.png");
- _menubg = new FlxSprite(0, 0, "assets/images/menubg.png");
- _menubg.setSize(FlxG.width, FlxG.height);
- add(_menubg);
- add(_image);
- add(_title);
- add(_playText);
- add(_dot);
- add(_optionsText);
- add(_quitText);
- FlxG.sound.playMusic("assets/music/8bitmelody.wav", 0.5, true);
- _image.animation.add("tick", [0, 1, 2, 3], 2, false);
- }
- override public function destroy():Void {
- }
- override public function update():Void {
- if (FlxG.keys.justPressed.DOWN) {
- if (currChoice < 2) { currChoice++; }
- else { currChoice = 0; }
- FlxG.sound.play("assets/sounds/select.wav", 1, false, true);
- _image.animation.play("tick");
- }
- else if (FlxG.keys.justPressed.UP) {
- if (currChoice > 0) { currChoice--; }
- else { currChoice = 2; }
- FlxG.sound.play("assets/sounds/select.wav", 1, false, true);
- }
- if (FlxG.keys.justPressed.ENTER) {
- if (currChoice == 0) {
- FlxG.camera.fade(FlxColor.BLACK,.33, false,function() {
- FlxG.switchState(new PlayState());
- });
- FlxG.sound.destroy(true);
- }
- else if (currChoice == 2)
- {
- System.exit(0);
- }
- }
- choose();
- }
- public function choose():Void {
- if (currChoice == 0) {
- _dot.setPosition(915, 415);
- }
- else if (currChoice == 1) {
- _dot.setPosition(915, 455);
- }
- else {
- _dot.setPosition(915, 495);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement