end.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. //Floor
  17. for(let i=0;i<9;i++){
  18. game.add.image(i*100, 501, 'floor');
  19. }
  20. // Progress bar
  21. for(let p=1;p<=5;p++){
  22. let block = game.add.image(660+(p-1)*30, 10, 'block');
  23. block.scale.setTo(2, 1); //Scaling to double width
  24. }
  25. game.add.text(820, 10, '100%', textStyles.subtitle3);
  26. game.add.text(650, 10, lang.difficulty + ' ' + levelDifficulty, textStyles.subtitle3).anchor.setTo(1,0);
  27. game.add.image(660, 10, 'pgbar');
  28. //School and trees
  29. game.add.sprite(600, 222 , 'school').scale.setTo(0.7);
  30. game.add.sprite(30, 280 , 'tree4');
  31. game.add.sprite(360, 250 , 'tree2');
  32. if(currentGameState == 'gameCircleOne'){
  33. //kid
  34. this.kid = game.add.sprite(0, -152 , 'kid_run');
  35. this.kid.anchor.setTo(0.5,0.5);
  36. this.kid.scale.setTo(0.7);
  37. this.kid.animations.add('walk', [0,1,2,3,4,5,6,7,8,9,10,11]);
  38. //globo
  39. this.balloon = game.add.sprite(0, -260, 'balloon');
  40. this.balloon.anchor.setTo(0.5,0.5);
  41. this.basket = game.add.sprite(0, -150, 'balloon_basket');
  42. this.basket.anchor.setTo(0.5,0.5);
  43. }else{
  44. //kid
  45. this.kid = game.add.sprite(0, 460 , 'kid_run');
  46. this.kid.anchor.setTo(0.5,0.5);
  47. this.kid.scale.setTo(0.7);
  48. this.kid.animations.add('walk', [0,1,2,3,4,5,6,7,8,9,10,11]);
  49. this.kid.animations.play('walk', 6, true);
  50. }
  51. },
  52. update: function(){
  53. if(currentGameState == 'gameCircleOne'){
  54. if(this.kid.y>=460){
  55. this.kid.animations.play('walk', 6, true);
  56. if(this.kid.x<=700){
  57. this.kid.x += 2;
  58. }else{
  59. passedLevels = 0;
  60. game.state.start('menu');
  61. }
  62. }else{
  63. this.balloon.y += 2;
  64. this.basket.y += 2;
  65. this.kid.y +=2;
  66. this.balloon.x += 1;
  67. this.basket.x += 1;
  68. this.kid.x +=1;
  69. }
  70. }else{
  71. if(this.kid.x <= 700){
  72. this.kid.x += 2;
  73. }else{
  74. passedLevels = 0;
  75. game.state.start('menu');
  76. }
  77. }
  78. },
  79. }