phaser/examples/wip/bmd2.js

52 lines
1 KiB
JavaScript
Raw Normal View History

2013-11-15 20:40:39 +00:00
2013-11-17 12:31:57 +00:00
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
2013-11-15 20:40:39 +00:00
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
game.load.image('ball', 'assets/sprites/shinyball.png');
}
var bmd;
function create() {
2013-11-17 04:33:16 +00:00
bmd = game.add.bitmapData(800, 600);
2013-11-15 20:40:39 +00:00
2013-11-17 04:33:16 +00:00
console.log('isLittleEndian', bmd.isLittleEndian);
bmd.isLittleEndian = false;
bmd.beginPath();
bmd.beginLinearGradientFill(["#ff0000", "#ffff00"], [0, 1], 0, 0, 0, 600);
bmd.rect(0, 0, 800, 600);
bmd.closePath();
bmd.fill();
bmd.refreshBuffer();
2013-11-15 20:40:39 +00:00
for (var i = 0; i < 100; i++)
{
2013-11-17 04:33:16 +00:00
bmd.setPixel(game.world.randomX, game.world.randomY, 0, 0, 0);
2013-11-15 20:40:39 +00:00
}
var d = game.add.sprite(0, 0, bmd);
}
function update() {
2013-11-17 04:33:16 +00:00
bmd.refreshBuffer();
bmd.setPixel(game.input.x, game.input.y, 0, 0, 0);
2013-11-15 20:40:39 +00:00
}
function render() {
2013-11-17 00:55:28 +00:00
bmd.render();
2013-11-15 20:40:39 +00:00
}