Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package game;
- import flixel.FlxG;
- import flixel.FlxState;
- import flixel.FlxSprite;
- import flixel.text.FlxText;
- class ShopState extends FlxState
- {
- private var bellyButton:FlxText;
- private var uravity:FlxText;
- private var oneForAll:FlxText;
- private var exit:FlxText;
- public static var bellyButtonAMNT:Int = 0;
- public static var uravityAMNT:Int = 0;
- public static var oneForAllAMNT:Int = 0;
- private var currentSelected:Int = 0;
- private var interactiveElement:FlxText;
- override public function create():Void
- {
- super.create();
- initShopItems();
- initInteractive();
- }
- private function initShopItems():Void
- {
- bellyButton = new FlxText();
- bellyButton.text = "Belly Button = x" + bellyButtonAMNT;
- bellyButton.size = 30;
- add(bellyButton);
- uravity = new FlxText(0, bellyButton.y);
- uravity.text = "Uravity = x" + uravityAMNT;
- uravity.size = 30;
- uravity.y += 50;
- add(uravity);
- oneForAll = new FlxText(0, uravity.y);
- oneForAll.text = "One For All = x" + oneForAllAMNT;
- oneForAll.size = 30;
- oneForAll.y += 50;
- add(oneForAll);
- exit = new FlxText(0, oneForAll.y);
- exit.text = "Exit";
- exit.size = 30;
- exit.y += 50;
- add(exit);
- }
- private function initInteractive():Void
- {
- interactiveElement = new FlxText();
- interactiveElement.text = "<-";
- interactiveElement.size = 50;
- add(interactiveElement);
- }
- override public function update(elapsed:Float):Void
- {
- handleInput();
- handleInteractive();
- super.update(elapsed);
- updateText();
- }
- private function handleInput():Void
- {
- /*
- if (FlxG.keys.justPressed.ENTER)
- FlxG.switchState(new PlayState());
- */
- }
- private function handleInteractive():Void
- {
- switch (currentSelected)
- {
- case 0: interactiveElement.setPosition(bellyButton.x + bellyButton.width, bellyButton.y);
- case 1: interactiveElement.setPosition(uravity.x + uravity.width, uravity.y);
- case 2: interactiveElement.setPosition(oneForAll.x + oneForAll.width, oneForAll.y);
- case 3: interactiveElement.setPosition(exit.x + exit.width, exit.y);
- }
- if (FlxG.keys.justPressed.UP || FlxG.keys.justPressed.W)
- currentSelected--;
- if (FlxG.keys.justPressed.DOWN || FlxG.keys.justPressed.S)
- currentSelected++;
- if (FlxG.keys.justPressed.ENTER)
- {
- switch (currentSelected)
- {
- case 0: bellyButtonAMNT++;
- case 1: uravityAMNT++;
- case 2: oneForAllAMNT++;
- case 3: FlxG.switchState(new PlayState());
- }
- }
- if (currentSelected < 0)
- currentSelected = 3;
- if (currentSelected > 3)
- currentSelected = 0;
- }
- private function updateText():Void
- {
- bellyButton.text = "Belly Button = x" + bellyButtonAMNT;
- uravity.text = "Uravity = x" + uravityAMNT;
- oneForAll.text = "One For All = x" + oneForAllAMNT;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement