Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class Intro extends Phaser.Scene {
- private _logo: Phaser.GameObjects.Image;
- private _cursors: Phaser.Types.Input.Keyboard.CursorKeys;
- private _last_pos: integer = 0 ;
- private KeyUP_alreadyclicked : any ;
- private KeyDOWN_alreadyclicked : any ;
- private _SPACE_button : any ;
- private _ENTER_button : any ;
- private _rettangolo : any ;
- private _testo_crediti : Phaser.GameObjects.BitmapText ;
- private _testo_comandi : Phaser.GameObjects.BitmapText ;
- private _gioca : Phaser.GameObjects.BitmapText;
- private _guida : Phaser.GameObjects.BitmapText;
- private _crediti : Phaser.GameObjects.BitmapText;
- private _orso : any ;
- private _bottone1 : boolean = false ;
- private _bottone2 : boolean = false;
- private _bottone11 : boolean = false ;
- private _bottone22 : boolean = false;
- constructor()
- {
- super( { key: "Intro", } );
- }
- preload()
- {
- }
- create()
- {
- this.cameras.main.setBackgroundColor("#782045");
- console.log("create:intro");
- //dichiarazione immagine gioco
- this._logo = this.add.image(this.game.canvas.width / 2, this.game.canvas.height / 4, "logo-gioco").setScale(5, 5);
- 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);
- 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);
- 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) ;
- //dichiarazione testo
- 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", () =>
- {
- this.scene.start("GamePlay");
- });
- 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", () =>
- {
- });
- 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", () =>
- {
- console.log("stai premendo il tasto crediti col mouse");
- });
- //dichiarazione cursore
- this._cursors = this.input.keyboard.createCursorKeys();
- //DICHIARAZIONE TASTI
- this._SPACE_button = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE);
- this._ENTER_button = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ENTER);
- this.KeyUP_alreadyclicked = false;
- this.KeyDOWN_alreadyclicked = false;
- //ORSO CHE SBATTE
- 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);
- }
- update(time: number, delta: number): void
- {
- this._logo.rotation += .01;
- this._orso.rotation +=0.01 ;
- this.funzione();
- }
- funzione()
- {
- if(this._cursors.down.isUp)
- {
- if(this._cursors.up.isDown)
- {
- if(this.KeyUP_alreadyclicked == false)
- {
- this._last_pos--;
- this.KeyUP_alreadyclicked = true;
- }
- }
- else
- {
- this.KeyUP_alreadyclicked = false;
- }
- }
- if(this._cursors.down.isDown)
- {
- if(this.KeyDOWN_alreadyclicked == false)
- {
- this._last_pos++;
- this.KeyDOWN_alreadyclicked = true;
- }
- }
- else
- {
- this.KeyDOWN_alreadyclicked = false;
- }
- if (this._last_pos > 3)
- {
- this._last_pos = 3 ;
- }
- if (this._last_pos < 1)
- {
- this._last_pos = 1 ;
- }
- if (this._last_pos == 1 )
- {
- this._guida.setTint(0x000000);
- this._crediti.setTint(0x000000);
- this._gioca.setTint(0x0000ff);
- if(this._SPACE_button.isDown || this._ENTER_button.isDown )
- {
- this.scene.start("GamePlay");
- }
- }
- if (this._last_pos == 2 )
- {
- this._guida.setTint(0x0000ff);
- this._crediti.setTint(0x000000);
- this._gioca.setTint(0x000000);
- if(this._SPACE_button.isDown || this._ENTER_button.isDown )
- {
- this._rettangolo.setAlpha(0.5);
- this._testo_comandi.setAlpha(1);
- console.log("comandi aperti con tastiera") ;
- }
- else
- {
- this.chiusura();
- }
- }
- this._guida.setInteractive().on("pointerup", () => { this._bottone1 = true ; });
- if(this._bottone1 == true)
- {
- this._guida.setInteractive().on("pointerup", () => { this._bottone1 = false ;});
- }
- if(this._bottone1 == true)
- {
- this._last_pos = 2;
- this._testo_crediti.setAlpha(0);
- this._rettangolo.setAlpha(0.5);
- this._testo_comandi.setAlpha(1);
- console.log("crediti aperti col mouse") ;
- }
- else
- {
- //this.chiusura();
- }
- if(this._last_pos == 3)
- {
- this._guida.setTint(0x000000);
- this._crediti.setTint(0x0000ff);
- this._gioca.setTint(0x000000);
- if(this._SPACE_button.isDown || this._ENTER_button.isDown )
- {
- this._rettangolo.setAlpha(0.5);
- this._testo_crediti.setAlpha(1);
- console.log("crediti aperti con tastiera");
- }
- else
- {
- this.chiusura();
- }
- }
- this._crediti.setInteractive().on("pointerup", () => { this._bottone2 = true ; });
- if(this._bottone2 == true)
- {
- this._crediti.setInteractive().on("pointerup", () => { this._bottone2 = false ; });
- }
- if(this._bottone2 == true)
- {
- this._last_pos = 3;
- this._testo_comandi.setAlpha(0);
- this._rettangolo.setAlpha(0.5);
- this._testo_crediti.setAlpha(1);
- console.log("crediti aperti con mouse");
- }
- else
- {
- //this.chiusura();
- }
- }
- chiusura() :void
- {
- this._rettangolo.setAlpha(0);
- this._testo_crediti.setAlpha(0);
- this._testo_comandi.setAlpha(0);
- console.log("รจ stato chiuso");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment