gameLevel1.create = function() {
this.physics.world.setBounds(0, 0, 1600, 600);
background = this.add.image(400, 300, 'background');
score = 0;
scoreText = this.add.text(16, 16, 'score: 0', { fontSize: '32px', fill: '#000' });
wichLevel = this.add.text(300, 16, 'Level 1', { fontSize: '16px', fill: '#000' });
pauseButton = this.add.sprite(350, 100, 'pauseSprite', 0).setScale(1);
pauseButton.setInteractive({ cursor: 'pointer' });
pauseButton.on('pointerdown', () => {
if (this.anims.paused)
{
this.anims.resumeAll();
console.log("play");
this.physics.resume();
}
else
{
this.anims.pauseAll();
console.log("pause");
this.physics.pause();
}
}, this);
pauseButton.on('pointerover', () => { pauseButton.setFrame(1); });
pauseButton.on('pointerout', () => { pauseButton.setFrame(0); });
hud = this.add.container(0, 0, [background, scoreText, wichLevel, pauseButton]);
hud.setScrollFactor(0);
player = this.physics.add.sprite(50, 50, 'playerSprite');
player.setBounce(0);
player.setCollideWorldBounds(true);
player.body.allowGravity = false;
stars = this.physics.add.group({
key: 'starSprite',
repeat: 11,
setXY: { x: 12, y: 0, stepX: 0 }
});
stars.children.iterate(function(child) {
child.setBounceY(Phaser.Math.FloatBetween(0.4, 0.8));
});
bombs = this.physics.add.group();
this.physics.add.overlap(player, stars, collectStar, null, this);
this.physics.add.collider(player, platforms);
this.physics.add.collider(stars, platforms);
this.physics.add.collider(bombs, platforms);
this.physics.add.collider(player, bombs, hitBomb, null, this);
camera = this.cameras.main;
camera.setBounds(0, 0, 1600, 800);
camera.startFollow(player, true, 0.05, 0.05, 0, 0);
cursors = this.input.keyboard.createCursorKeys();
};
How can i tell?
My mouse pointer remains the same when player had moved and I hover above the pauseButton. And when I go to the same direction of wich the player moved, but then from the button I see that my moise poiter changes in the hand and the animation of the button sprite works.