kozubovskyy

Untitled

Mar 1st, 2023
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. export default class Intro extends Phaser.Scene {
  2.  
  3. private _logo: Phaser.GameObjects.Image;
  4. private _cursors: Phaser.Types.Input.Keyboard.CursorKeys;
  5. private _last_pos: integer = 0 ;
  6.  
  7. private KeyUP_alreadyclicked : any ;
  8. private KeyDOWN_alreadyclicked : any ;
  9.  
  10. private _SPACE_button : any ;
  11. private _ENTER_button : any ;
  12.  
  13. private _rettangolo : any ;
  14. private _testo_crediti : Phaser.GameObjects.BitmapText ;
  15. private _testo_comandi : Phaser.GameObjects.BitmapText ;
  16. private _gioca : Phaser.GameObjects.BitmapText;
  17.  
  18.  
  19. private _guida : Phaser.GameObjects.BitmapText;
  20. private _crediti : Phaser.GameObjects.BitmapText;
  21.  
  22. private _orso : any ;
  23.  
  24.  
  25. private _bottone1 : boolean = false ;
  26. private _bottone2 : boolean = false;
  27.  
  28. private _bottone11 : boolean = false ;
  29. private _bottone22 : boolean = false;
  30.  
  31.  
  32.  
  33. constructor()
  34. {
  35. super( { key: "Intro", } );
  36. }
  37.  
  38. preload()
  39. {
  40.  
  41. }
  42.  
  43. create()
  44. {
  45. this.cameras.main.setBackgroundColor("#782045");
  46. console.log("create:intro");
  47.  
  48. //dichiarazione immagine gioco
  49. this._logo = this.add.image(this.game.canvas.width / 2, this.game.canvas.height / 4, "logo-gioco").setScale(5, 5);
  50.  
  51.  
  52. this._testo_comandi = this.add.bitmapText(this.game.canvas.width/2, this.game.canvas.height/2, "arcade" , "testo comando").setOrigin(0.5 , 0.5).setAlpha(0);
  53. this._testo_crediti = this.add.bitmapText(this.game.canvas.width/2, this.game.canvas.height/2, "arcade" , "testo crediti").setOrigin(0.5 , 0.5).setAlpha(0);
  54. this._rettangolo = this.add.rectangle(this.game.canvas.width/2, this.game.canvas.height/2, 824, 500 , 0x000000).setOrigin(0.5 , 0.5).setAlpha(0).setDepth(10) ;
  55.  
  56. //dichiarazione testo
  57. this._gioca = this.add.bitmapText(this.game.canvas.width/2, ((this.game.canvas.height/2)+25), "arcade" , "GIOCA", 40).setOrigin(0.5 , 0.5).setInteractive().on("pointerup", () =>
  58. {
  59. this.scene.start("GamePlay");
  60. });
  61.  
  62. this._guida = this.add.bitmapText(this.game.canvas.width/2, ((this.game.canvas.height/2)+125), "arcade" , "GUIDA", 40).setOrigin(0.5 , 0.5).setInteractive().on("pointerup", () =>
  63. {
  64.  
  65. });
  66.  
  67. this._crediti = this.add.bitmapText(this.game.canvas.width/2, ((this.game.canvas.height/2)+225), "arcade" , "CREDITI", 40).setOrigin(0.5 , 0.5).setInteractive().on("pointerup", () =>
  68. {
  69. console.log("stai premendo il tasto crediti col mouse");
  70. });
  71.  
  72.  
  73.  
  74.  
  75. //dichiarazione cursore
  76. this._cursors = this.input.keyboard.createCursorKeys();
  77.  
  78.  
  79. //DICHIARAZIONE TASTI
  80. this._SPACE_button = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE);
  81. this._ENTER_button = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ENTER);
  82. this.KeyUP_alreadyclicked = false;
  83. this.KeyDOWN_alreadyclicked = false;
  84.  
  85.  
  86. //ORSO CHE SBATTE
  87. this._orso = this.physics.add.image(Phaser.Math.RND.realInRange(0, 1024), Phaser.Math.RND.realInRange(0, 600), 'logo-procione-png').setVelocity(-80, -80).setBounce(1).setCollideWorldBounds(true).setScale(0.2 , 0.2 ).setAlpha(0.9);
  88. }
  89.  
  90.  
  91. update(time: number, delta: number): void
  92.  
  93. {
  94. this._logo.rotation += .01;
  95. this._orso.rotation +=0.01 ;
  96. this.funzione();
  97. }
  98.  
  99. funzione()
  100. {
  101. if(this._cursors.down.isUp)
  102. {
  103. if(this._cursors.up.isDown)
  104. {
  105. if(this.KeyUP_alreadyclicked == false)
  106. {
  107. this._last_pos--;
  108. this.KeyUP_alreadyclicked = true;
  109. }
  110. }
  111. else
  112. {
  113. this.KeyUP_alreadyclicked = false;
  114. }
  115. }
  116. if(this._cursors.down.isDown)
  117. {
  118. if(this.KeyDOWN_alreadyclicked == false)
  119. {
  120. this._last_pos++;
  121. this.KeyDOWN_alreadyclicked = true;
  122. }
  123. }
  124. else
  125. {
  126. this.KeyDOWN_alreadyclicked = false;
  127. }
  128. if (this._last_pos > 3)
  129. {
  130. this._last_pos = 3 ;
  131. }
  132. if (this._last_pos < 1)
  133. {
  134. this._last_pos = 1 ;
  135. }
  136. if (this._last_pos == 1 )
  137. {
  138. this._guida.setTint(0x000000);
  139. this._crediti.setTint(0x000000);
  140. this._gioca.setTint(0x0000ff);
  141. if(this._SPACE_button.isDown || this._ENTER_button.isDown )
  142. {
  143. this.scene.start("GamePlay");
  144. }
  145. }
  146.  
  147. if (this._last_pos == 2 )
  148. {
  149. this._guida.setTint(0x0000ff);
  150. this._crediti.setTint(0x000000);
  151. this._gioca.setTint(0x000000);
  152. if(this._SPACE_button.isDown || this._ENTER_button.isDown )
  153. {
  154. this._rettangolo.setAlpha(0.5);
  155. this._testo_comandi.setAlpha(1);
  156. console.log("comandi aperti con tastiera") ;
  157. }
  158. else
  159. {
  160. this.chiusura();
  161. }
  162. }
  163.  
  164. this._guida.setInteractive().on("pointerup", () => { this._bottone1 = true ; });
  165. if(this._bottone1 == true)
  166. {
  167. this._guida.setInteractive().on("pointerup", () => { this._bottone1 = false ;});
  168. }
  169.  
  170. if(this._bottone1 == true)
  171. {
  172. this._last_pos = 2;
  173. this._testo_crediti.setAlpha(0);
  174. this._rettangolo.setAlpha(0.5);
  175. this._testo_comandi.setAlpha(1);
  176. console.log("crediti aperti col mouse") ;
  177. }
  178. else
  179. {
  180. //this.chiusura();
  181. }
  182.  
  183.  
  184.  
  185.  
  186.  
  187. if(this._last_pos == 3)
  188. {
  189. this._guida.setTint(0x000000);
  190. this._crediti.setTint(0x0000ff);
  191. this._gioca.setTint(0x000000);
  192. if(this._SPACE_button.isDown || this._ENTER_button.isDown )
  193. {
  194. this._rettangolo.setAlpha(0.5);
  195. this._testo_crediti.setAlpha(1);
  196. console.log("crediti aperti con tastiera");
  197. }
  198. else
  199. {
  200. this.chiusura();
  201.  
  202. }
  203.  
  204.  
  205. }
  206.  
  207.  
  208. this._crediti.setInteractive().on("pointerup", () => { this._bottone2 = true ; });
  209. if(this._bottone2 == true)
  210. {
  211. this._crediti.setInteractive().on("pointerup", () => { this._bottone2 = false ; });
  212. }
  213. if(this._bottone2 == true)
  214. {
  215. this._last_pos = 3;
  216. this._testo_comandi.setAlpha(0);
  217. this._rettangolo.setAlpha(0.5);
  218. this._testo_crediti.setAlpha(1);
  219. console.log("crediti aperti con mouse");
  220. }
  221. else
  222. {
  223. //this.chiusura();
  224. }
  225.  
  226. }
  227. chiusura() :void
  228. {
  229. this._rettangolo.setAlpha(0);
  230. this._testo_crediti.setAlpha(0);
  231. this._testo_comandi.setAlpha(0);
  232. console.log("รจ stato chiuso");
  233. }
  234. }
  235.  
  236.  
Advertisement
Add Comment
Please, Sign In to add comment