comicsState.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function ComicsState() {
  2. ComicsState.superclass.constructor.apply(this);
  3. this.back = null;
  4. this.frames = [];
  5. this.bNext = null;
  6. this.currentFrame = 0;
  7. this.framesLayer = null;
  8. this.a10Logo = null;
  9. }
  10. extend(ComicsState, TrinState);
  11. ComicsState.prototype.create = function() {
  12. ComicsState.superclass.create.apply(this);
  13. this.framesLayer = new TrinLayer();
  14. this.back = new TrinSprite();
  15. this.back.addAnimationFromCache("ComicsBack");
  16. this.bNext = new TrinButton(function() {
  17. _TrinGame.switchState(new LevelPackSelectState());
  18. }, "bNext", false);
  19. this.bNext.orign.x = this.bNext.width;
  20. this.bNext.orign.y = this.bNext.height;
  21. this.bNext.reset(632, _TrinGame.visibleArea.bottom - 8);
  22. var frame;
  23. for (var i = 0; i < 3; i++) {
  24. frame = new TrinSprite();
  25. frame.addAnimationFromCache("ComicsFrame" + i);
  26. frame.alpha = 0;
  27. this.frames[i] = frame;
  28. this.framesLayer.add(frame);
  29. }
  30. var a10Logo = new TrinButton(function() {
  31. //_TrinGame.SPIL_LOGO.action();
  32. }, "A10Logo", true);
  33. a10Logo.orign.y = a10Logo.height;
  34. a10Logo.reset(8, _TrinGame.visibleArea.bottom - 8);
  35. this.a10Logo = a10Logo;
  36. this.add(this.back);
  37. this.add(this.framesLayer);
  38. this.add(this.bNext);
  39. this.add(a10Logo);
  40. };
  41. ComicsState.prototype.update = function() {
  42. ComicsState.superclass.update.apply(this);
  43. var frame = this.frames[this.currentFrame];
  44. if (frame !== undefined) {
  45. if (frame.alpha < 1) {
  46. var d = 0.025;
  47. if (_TrinGame.mouse.isDown()) {
  48. d *= 4;
  49. }
  50. frame.alpha = Math.min(frame.alpha + d, 1);
  51. } else {
  52. this.currentFrame++;
  53. }
  54. frame.x = frame.y = -10 * (1 - frame.alpha);
  55. }
  56. };
  57. ComicsState.prototype.resized = function() {
  58. this.bNext.y = this.a10Logo.y = _TrinGame.visibleArea.bottom - 8;
  59. };