2013-12-31 17:35:40 +00:00
|
|
|
|
|
|
|
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
|
|
|
|
|
|
|
function preload() {
|
|
|
|
|
|
|
|
game.load.image('ball', 'assets/sprites/shinyball.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var sprite;
|
|
|
|
var particles = [];
|
|
|
|
var bmd;
|
|
|
|
|
|
|
|
var u = 0;
|
|
|
|
var n = 0;
|
|
|
|
var oldn = 0;
|
|
|
|
var ad = 0;
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
bmd = game.add.bitmapData(800, 600);
|
2013-12-31 17:35:40 +00:00
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
for (var i = 0; i < 60; i++)
|
2013-12-31 17:35:40 +00:00
|
|
|
{
|
|
|
|
particles.push(new Phaser.Point(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
sprite = game.add.sprite(0, 0, bmd);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function mycircle(context, x, y, R, color) {
|
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
//R = 64;
|
|
|
|
|
2013-12-31 17:35:40 +00:00
|
|
|
context.fillStyle = color;
|
|
|
|
context.beginPath();
|
|
|
|
context.arc(x, y, R, 0, Math.PI * 2, true);
|
|
|
|
context.closePath();
|
|
|
|
context.fill();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
|
|
|
bmd.clear();
|
|
|
|
|
|
|
|
oldn = n;
|
|
|
|
|
|
|
|
for (var t = 0; t < particles.length; t++)
|
|
|
|
{
|
|
|
|
var p = particles[t];
|
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
// p.x = Math.sin(n) * 50 + Math.cos(n * 1.5) * 300;
|
|
|
|
// p.y = Math.sin(n / 2) * 20 + Math.sin(n * 2) * 250;
|
|
|
|
|
|
|
|
p.x = Math.cos(n) * 50 + Math.sin(n * 1.5) * 300;
|
|
|
|
p.y = Math.cos(n / 2) * 20 + Math.cos(n * 2) * 250;
|
2013-12-31 17:35:40 +00:00
|
|
|
|
|
|
|
var tx = p.x;
|
|
|
|
var ty = p.y;
|
|
|
|
|
|
|
|
bmd.context.globalCompositeOperation = 'xor';
|
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
//mycircle(bmd.context, p.x + 400, p.y + 300, Math.sin(t * 360 / particles.length / 2 * Math.PI / 180) * 50, 'rgba(255, 255, 0, 1)');
|
|
|
|
mycircle(bmd.context, p.x + 400, p.y + 300, Math.sin(t * 360 / particles.length / 2 * Math.PI / 180) * 50, 'rgba(255, 255, 0, 1)');
|
2013-12-31 17:35:40 +00:00
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
n += 0.05;
|
2013-12-31 17:35:40 +00:00
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
//bmd.context.globalCompositeOperation = 'source-over';
|
2013-12-31 17:35:40 +00:00
|
|
|
}
|
|
|
|
|
2014-01-03 02:24:06 +00:00
|
|
|
n = oldn + 0.02;
|
2013-12-31 17:35:40 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
|
|
|
|
}
|