0% found this document useful (0 votes)
38 views

scnMenu - Create Script

The document outlines a function that creates a game scene with a background image, a play button, and a title. It includes animations for the title and button, as well as interactive event listeners for mouse actions like hover, click, and release. The play button transitions to a new scene when clicked, and visual feedback is provided during interactions.

Uploaded by

andikapratamats
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

scnMenu - Create Script

The document outlines a function that creates a game scene with a background image, a play button, and a title. It includes animations for the title and button, as well as interactive event listeners for mouse actions like hover, click, and release. The play button transitions to a new scene when clicked, and visual feedback is provided during interactions.

Uploaded by

andikapratamats
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

function create(){

this.add.image(1024/2, 768/2, 'bg_start');

var btnPlay = this.add.image(1024/2, 768/2 + 75, 'btn_play');


btnPlay.setDepth(10);

this.titleGame = this.add.image(1024/2, 200, 'title_game');


this.titleGame.setDepth(10);

this.titleGame.y -= 384;

var diz = this;

this.tweens.add({
targets: diz.titleGame,
ease: 'Bounce.easeOut',
duration: 750,
delay: 250,
y: 200
});

this.titleGame.setScale(0);

this.tweens.add({
targets: diz.titleGame,
ease: 'Elastic',
duration: 750,
delay:1000,
scaleX:1,
scaleY:1
});

btnPlay.setScale(0);

this.tweens.add({
targets: btnPlay,
ease: 'Back',
duration: 500,
delay: 750,
scaleX : 1,
scaleY : 1
});

btnPlay.setInteractive();

var btnCliked = false;

this.input.on('gameobjectover', function (pointer, gameObject) {


console.log("Scene Menu | Object Over");

if (!btnCliked) return;

if (gameObject == btnPlay) {
btnPlay.setTint(0x616161);
}

}, this);

this.input.on('gameobjectout', function (pointer, gameoObject) {


console.log("Scene Menu | Object Out");

if (!btnCliked) return;

if (gameoObject == btnPlay) {
btnPlay.setTint(0xffffff);
}

}, this);

this.input.on('gameobjectdown', function (pointer, gameObject) {


console.log("Scene Menu | Object Click");

if (gameObject == btnPlay) {
btnPlay.setTint(0x616161);
btnCliked = true;
}

}, this);

this.input.on('gameobjectup', function (pointer, gameObject) {


console.log("Scene Menu | Object End Click");

if (gameObject == btnPlay) {
btnPlay.setTint(0xffffff);
this.scene.start('scnPlay');
}

}, this);

this.input.on('pointerup', function(pointer, currentlyOver) {


console.log("Scene Menu | Mouse Up");

btnCliked = false;

}, this);
}

You might also like