2013-09-06 14:00:05 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>phaser.js - a new beginning</title>
|
|
|
|
<?php
|
|
|
|
require('js.php');
|
|
|
|
?>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
|
|
|
|
|
|
|
function preload() {
|
|
|
|
game.load.image('diamond', 'assets/sprites/diamond.png');
|
2013-09-06 19:20:58 +00:00
|
|
|
game.load.image('carrot', 'assets/sprites/carrot.png');
|
2013-09-06 14:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var g;
|
|
|
|
var t;
|
|
|
|
var s;
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
2013-09-06 19:20:58 +00:00
|
|
|
t = game.add.sprite(100, 100, 'carrot');
|
|
|
|
t.name = 'c0';
|
|
|
|
t.body.bounce.y = Math.random();
|
|
|
|
t.body.collideWorldBounds = true;
|
|
|
|
|
|
|
|
g = game.add.group();
|
|
|
|
// g.x = 400;
|
|
|
|
// g.y = 300;
|
|
|
|
// g._container.anchor.x = 0.5;
|
|
|
|
// g._container.anchor.y = 0.5;
|
2013-09-06 14:00:05 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < 10; i++)
|
|
|
|
{
|
2013-09-11 12:21:07 +00:00
|
|
|
var x = 50 + (i * 64);
|
|
|
|
s = g.create(x, 100, 'diamond');
|
2013-09-06 19:20:58 +00:00
|
|
|
s.name = 'd' + i;
|
|
|
|
s.anchor.setTo(0.5, 0.5);
|
2013-09-06 14:00:05 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 19:20:58 +00:00
|
|
|
// g.forEach(setAlpha, this);
|
|
|
|
|
|
|
|
// g.dump();
|
|
|
|
|
|
|
|
// g.replace(s, t);
|
|
|
|
|
|
|
|
// g.dump();
|
2013-09-06 14:00:05 +00:00
|
|
|
|
2013-09-06 19:20:58 +00:00
|
|
|
// g.callAll('dump', game, 123, 456, 789);
|
|
|
|
|
|
|
|
// g.getRandom().y += 200;
|
|
|
|
|
|
|
|
// g.setAll('body.velocity.y', 250);
|
2013-09-06 14:00:05 +00:00
|
|
|
// g.divideAll('y', 2);
|
|
|
|
// g.multiplyAll('y', 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-09-06 19:20:58 +00:00
|
|
|
function setAlpha (sprite) {
|
|
|
|
sprite.alpha = 0.4;
|
|
|
|
}
|
|
|
|
|
2013-09-06 14:00:05 +00:00
|
|
|
function update() {
|
|
|
|
|
2013-09-11 12:21:07 +00:00
|
|
|
g.addAll('angle', 10);
|
|
|
|
// g.angle++;
|
2013-09-06 14:00:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|