Advertisement
Guest User

Clock anim

a guest
Jan 25th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. class MState extends FlxState
  2. {
  3. public var _image : FlxSprite;
  4. public var _title : FlxSprite;
  5. public var _playText : FlxText;
  6. public var _optionsText : FlxText;
  7. public var _quitText : FlxText;
  8. //public var _helpText : FlxText;
  9. public var currChoice : Int = 0;
  10. public var _dot : FlxSprite;
  11. public var _menubg : FlxSprite;
  12.  
  13. override public function create():Void {
  14. _image = new FlxSprite(0, 0);
  15. _image.loadGraphic("assets/images/clockanim.png", true, 400, 400);
  16. _title = new FlxSprite(0, 50, "assets/images/menutitle.png");
  17. //dot is 20x20
  18. _playText = new FlxText(935, 400, 100);
  19. _playText.text = "PLAY";
  20. _playText.setFormat("assets/data/font.otf", 32, FlxColor.WHITE);
  21. _optionsText = new FlxText(935, 440, 100);
  22. _optionsText.text = "OPTIONS";
  23. _optionsText.setFormat("assets/data/font.otf", 32, FlxColor.WHITE);
  24. _quitText = new FlxText(935, 480, 100);
  25. _quitText.text = "QUIT";
  26. _quitText.setFormat("assets/data/font.otf", 32, FlxColor.WHITE);
  27. FlxSpriteUtil.screenCenter(_image, true, true);
  28. FlxSpriteUtil.screenCenter(_title, true, false);
  29. _dot = new FlxSprite(500, 560, "assets/images/dot.png");
  30. _menubg = new FlxSprite(0, 0, "assets/images/menubg.png");
  31. _menubg.setSize(FlxG.width, FlxG.height);
  32. add(_menubg);
  33. add(_image);
  34. add(_title);
  35. add(_playText);
  36. add(_dot);
  37. add(_optionsText);
  38. add(_quitText);
  39. FlxG.sound.playMusic("assets/music/8bitmelody.wav", 0.5, true);
  40. _image.animation.add("tick", [0, 1, 2, 3], 2, false);
  41. }
  42.  
  43. override public function destroy():Void {
  44. }
  45.  
  46. override public function update():Void {
  47.  
  48. if (FlxG.keys.justPressed.DOWN) {
  49. if (currChoice < 2) { currChoice++; }
  50. else { currChoice = 0; }
  51. FlxG.sound.play("assets/sounds/select.wav", 1, false, true);
  52. _image.animation.play("tick");
  53. }
  54. else if (FlxG.keys.justPressed.UP) {
  55. if (currChoice > 0) { currChoice--; }
  56. else { currChoice = 2; }
  57. FlxG.sound.play("assets/sounds/select.wav", 1, false, true);
  58. }
  59.  
  60. if (FlxG.keys.justPressed.ENTER) {
  61. if (currChoice == 0) {
  62.  
  63. FlxG.camera.fade(FlxColor.BLACK,.33, false,function() {
  64. FlxG.switchState(new PlayState());
  65. });
  66. FlxG.sound.destroy(true);
  67.  
  68. }
  69. else if (currChoice == 2)
  70. {
  71. System.exit(0);
  72. }
  73.  
  74. }
  75.  
  76. choose();
  77. }
  78.  
  79. public function choose():Void {
  80.  
  81. if (currChoice == 0) {
  82. _dot.setPosition(915, 415);
  83. }
  84. else if (currChoice == 1) {
  85. _dot.setPosition(915, 455);
  86. }
  87. else {
  88. _dot.setPosition(915, 495);
  89. }
  90. }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement