kozubovskyy

Untitled

Feb 19th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 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.  
  8. constructor() {
  9. super({
  10. key: "Intro",
  11. });
  12.  
  13.  
  14. }
  15.  
  16. preload() {
  17.  
  18.  
  19. }
  20. create() {
  21.  
  22. this.cameras.main.setBackgroundColor("#782045");
  23. console.log("create:intro");
  24.  
  25.  
  26. //dichiarazione immagine gioco
  27. this._logo = this.add.image(this.game.canvas.width / 2, this.game.canvas.height / 4, "logo-gioco").setScale(9, 9);
  28.  
  29. //dichiarazione testo
  30. this.add.text(this.game.canvas.width/2, ((this.game.canvas.height/2)+50), 'Gioca', { color: '#000000' }).setInteractive().on("pointerup", () => {console.log("restartato")}).setOrigin(0.5 , 0.5);
  31. this.add.text(this.game.canvas.width/2, ((this.game.canvas.height/2)+125), 'Guida', { color: '#000000' }).setInteractive().on("pointerup", () => {console.log("restartato")}).setOrigin(0.5 , 0.5);
  32. this.add.text(this.game.canvas.width/2, ((this.game.canvas.height/2)+200), 'Crediti', { color: '#000000' }).setInteractive().on("pointerup", () => {console.log("restartato")}).setOrigin(0.5 , 0.5);
  33.  
  34. //dichiarazione cursore
  35. this._cursors = this.input.keyboard.createCursorKeys();
  36.  
  37.  
  38.  
  39.  
  40. }
  41.  
  42.  
  43. update(time: number, delta: number): void {
  44. this._logo.rotation += .01;
  45.  
  46. //se il tasto cursore down รจ premuto
  47. if (this._cursors.up.isDown) {
  48. console.log("sopra");
  49. this._last_pos ++ ;
  50. }
  51. //se il tasto cursore down รจ premuto
  52. else if (this._cursors.down.isDown) {
  53. console.log("giu");
  54. this._last_pos -- ;
  55. }
  56. console.log(this._last_pos) ;
  57.  
  58.  
  59.  
  60. }
  61.  
  62. }
  63.  
  64.  
Advertisement
Add Comment
Please, Sign In to add comment