forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpick images from cache.js
More file actions
35 lines (26 loc) · 1.2 KB
/
Copy pathpick images from cache.js
File metadata and controls
35 lines (26 loc) · 1.2 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
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.image('atari4', 'assets/sprites/atari800.png');
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
game.load.image('firstaid', 'assets/sprites/firstaid.png');
game.load.image('diamond', 'assets/sprites/diamond.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
// This returns an array of all the image keys in the cache
var images = game.cache.getKeys(Phaser.Cache.IMAGE);
// Now let's create some random sprites and enable them all for drag and 'bring to top'
for (var i = 0; i < 20; i++)
{
var img = game.rnd.pick(images);
var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, img);
tempSprite.inputEnabled = true;
tempSprite.input.enableDrag(false, true);
}
}
function render() {
game.debug.inputInfo(32, 32);
}