mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
38 lines
747 B
JavaScript
38 lines
747 B
JavaScript
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
|
|
|
function preload() {
|
|
|
|
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
|
|
|
|
}
|
|
|
|
var group;
|
|
var texture;
|
|
|
|
function create() {
|
|
|
|
group = game.add.group();
|
|
group.create(0, 0, 'veggies', 0);
|
|
group.create(32, 0, 'veggies', 1);
|
|
group.create(0, 32, 'veggies', 2);
|
|
group.create(32, 32, 'veggies', 3);
|
|
group.visible = false;
|
|
|
|
texture = game.add.renderTexture('texture', 800, 600);
|
|
|
|
game.add.sprite(0, 0, texture);
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
var clear = false;
|
|
|
|
for (var i = 0; i < 60; i++)
|
|
{
|
|
clear = (i == 0);
|
|
texture.renderXY(group, game.world.randomX, game.world.randomY, clear);
|
|
}
|
|
|
|
}
|