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

scnPlay - Create Script

The function 'create' initializes a game scene with backgrounds and a character. It sets up background images with specific speeds and scales the character using tweens. The game starts upon completing the character's scaling animation, and user input triggers a movement animation for the character.

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)
5 views

scnPlay - Create Script

The function 'create' initializes a game scene with backgrounds and a character. It sets up background images with specific speeds and scales the character using tweens. The game starts upon completing the character's scaling animation, and user input triggers a movement animation for the character.

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.backgrounds = [];
this.timerHalangan = 0;
this.halangan = [];

var bg_x = 1366/2;

for (let i = 0; i < 2; i++)


{
var bg_awal = [];

var BG = this.add.image(bg_x,768/2,'fg_loop_back');
var FG = this.add.image(bg_x,768/2,'fg_loop');

BG.setData('kecepatan', 2);
FG.setData('kecepatan', 4);
FG.setDepth(2);

bg_awal.push(BG);
bg_awal.push(FG);

this.backgrounds.push(bg_awal);

bg_x += 1366;
}

this.chara = this.add.image(130, 768/2, 'chara');


this.chara.setDepth(3);

this.chara.setScale(0);

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

this.isGameRunning = false;

var myScene = this;

this.tweens.add({
delay: 250,
targets: this.chara,
ease: 'Back.Out',
duration: 500,
scaleX : 1,
scaleY : 1,
onComplete: function(){
myScene.isGameRunning = true;
}
});

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


console.log("Scene Play | Mouse Pointer Up");

if (!this.isGameRunning) return;

this.charaTweens = this.tweens.add({
targets: this.chara,
ease: 'Power1',
duration: 750,
y: this.chara.y + 200
});
}, this);
}

You might also like