phaser/examples/groups/group transform - rotate.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2013-10-22 02:58:20 +00:00
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var robot;
function preload() {
game.load.image('eye', 'assets/sprites/robot/eye.png');
game.load.image('body', 'assets/sprites/robot/body.png');
game.load.image('arm-l', 'assets/sprites/robot/arm-l.png');
game.load.image('arm-r', 'assets/sprites/robot/arm-r.png');
game.load.image('leg-l', 'assets/sprites/robot/leg-l.png');
game.load.image('leg-r', 'assets/sprites/robot/leg-r.png');
}
function create() {
// Use groups of sprites to create a big robot.
// Robot itself, you can subclass group class in a real game.
robot = game.add.group();
2014-02-01 04:54:02 +00:00
robot.x = 300;
robot.y = 200;
robot.pivot.x = 300;
robot.pivot.y = 300;
2013-10-22 02:58:20 +00:00
// Robot components.
2014-02-01 04:54:02 +00:00
robot.create(90, 175, 'arm-l');
robot.create(549, 175, 'arm-r');
robot.create(270, 325, 'leg-l');
robot.create(410, 325, 'leg-r');
robot.create(219, 32, 'body');
robot.create(335, 173,'eye');
2013-10-22 02:58:20 +00:00
}
function update() {
robot.rotation += 0.02;
2013-10-22 02:58:20 +00:00
}
function render() {
game.debug.renderText('The robot is a group and every component is a sprite.', 240, 580);
}