end.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. let endState = {
  3. create: function(){},
  4. update: function(){},
  5. ---------------------------- end of phaser functions
  6. };
  7. */
  8. endState = {
  9. create: function(){
  10. // Background
  11. game.add.image(0, 0, 'bgimage');
  12. //Clouds
  13. game.add.image(300, 100, 'cloud');
  14. game.add.image(660, 80, 'cloud');
  15. game.add.image(110, 85, 'cloud').scale.setTo(0.8);
  16. // Styles for labels
  17. let style = { font: '30px Arial', fill: '#000000', align: 'center'};
  18. //Floor
  19. for(let i=0;i<9;i++){
  20. game.add.image(i*100, 501, 'floor');
  21. }
  22. // Progress bar
  23. for(let p=1;p<=5;p++){
  24. let block = game.add.image(660+(p-1)*30, 10, 'block');
  25. block.scale.setTo(2, 1); //Scaling to double width
  26. }
  27. game.add.text(820, 10, '100%', style);
  28. game.add.text(650, 10, lang.difficulty + ' ' + levelDifficulty, style).anchor.setTo(1,0);
  29. game.add.image(660, 10, 'pgbar');
  30. //School and trees
  31. game.add.sprite(600, 222 , 'school').scale.setTo(0.7);
  32. game.add.sprite(30, 280 , 'tree4');
  33. game.add.sprite(360, 250 , 'tree2');
  34. if(gameStateString == 'gameCircleOne'){
  35. //kid
  36. this.kid = game.add.sprite(0, -152 , 'kid_run');
  37. this.kid.anchor.setTo(0.5,0.5);
  38. this.kid.scale.setTo(0.7);
  39. this.kid.animations.add('walk', [0,1,2,3,4,5,6,7,8,9,10,11]);
  40. //globo
  41. this.balloon = game.add.sprite(0, -260, 'balloon');
  42. this.balloon.anchor.setTo(0.5,0.5);
  43. this.basket = game.add.sprite(0, -150, 'balloon_basket');
  44. this.basket.anchor.setTo(0.5,0.5);
  45. }else{
  46. //kid
  47. this.kid = game.add.sprite(0, 460 , 'kid_run');
  48. this.kid.anchor.setTo(0.5,0.5);
  49. this.kid.scale.setTo(0.7);
  50. this.kid.animations.add('walk', [0,1,2,3,4,5,6,7,8,9,10,11]);
  51. this.kid.animations.play('walk', 6, true);
  52. }
  53. },
  54. update: function(){
  55. if(gameStateString == 'gameCircleOne'){
  56. if(this.kid.y>=460){
  57. this.kid.animations.play('walk', 6, true);
  58. if(this.kid.x<=700){
  59. this.kid.x += 2;
  60. }else{
  61. if(levelMenu){
  62. passedLevels = 0;
  63. game.state.start('menu');
  64. }else{
  65. this.kid.animations.stop();
  66. }
  67. }
  68. }else{
  69. this.balloon.y += 2;
  70. this.basket.y += 2;
  71. this.kid.y +=2;
  72. this.balloon.x += 1;
  73. this.basket.x += 1;
  74. this.kid.x +=1;
  75. }
  76. }else{
  77. if(this.kid.x <= 700){
  78. this.kid.x += 2;
  79. }else{
  80. if(levelMenu){
  81. passedLevels = 0;
  82. game.state.start('menu');
  83. }else{
  84. this.kid.animations.stop();
  85. }
  86. }
  87. }
  88. },
  89. }