-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjs.js
More file actions
69 lines (45 loc) · 1.27 KB
/
js.js
File metadata and controls
69 lines (45 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const gameState = {};
function preload() {
// Load in the sprite sheet below:
this.load.spritesheet('codey','https://cors-anywhere.herokuapp.com/https://sosproject2014djj.files.wordpress.com/2014/06/pygmy_sprite_preview.png',{ frameWidth:999, frameHeight: 1180 })
}
function create() {
// gameState.active is true if the game is playble (not game over)
gameState.active = true;
// Creates the background image
// Creates platforms group
gameState.player=this.physics.add.sprite(1500,800,'codey').setScale(.19);
gameState.player.setCollideWorldBounds(true)
this.anims.create({
key: 'run',
frames: this.anims.generateFrameNumbers('codey', { start: 0, end: 3 }),
frameRate: 5,
repeat: -1
})
}
function update() {
if (gameState.active) {
gameState.player.setVelocityX(-152);
// Add your code below:
gameState.player.anims.play('run',true)
}
}
const config = {
type: Phaser.AUTO,
width: 1500,
height: 260,
backgroundColor:"#7FFFD4",
physics: {
default: 'arcade',
arcade: {
gravity: { y: 1500 },
enableBody: true,
}
},
scene: {
preload,
create,
update
}
};
const game = new Phaser.Game(config);