This commit is contained in:
Richard Davey
2013-09-07 21:12:47 +01:00
parent eb7af3d2a2
commit bb5d8ca170
3 changed files with 439 additions and 526 deletions
+387 -521
View File
File diff suppressed because it is too large Load Diff
+45
View File
@@ -0,0 +1,45 @@
<!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('ship', 'assets/sprites/mana_card.png');
}
var player;
var aliens;
function create() {
player = game.add.sprite(400, 300, 'ship');
player.anchor.setTo(0.5, 0.5);
}
function update() {
player.angle++;
}
function render() {
game.debug.renderSpriteCorners(player,true,true);
game.debug.renderRectangle(player.body.bounds);
}
})();
</script>
</body>
</html>
+7 -5
View File
@@ -95,8 +95,8 @@ Phaser.Physics.Arcade.Body.prototype = {
this.lastX = this.x;
this.lastY = this.y;
this.x = this.sprite.x;
this.y = this.sprite.y;
this.x = this.sprite.x - this.offset.x + (this.sprite.anchor.x * this.width));
this.y = this.sprite.y - this.offset.y + (this.sprite.anchor.y * this.height));
this.rotation = this.sprite.angle;
if (this.moves)
@@ -120,12 +120,14 @@ Phaser.Physics.Arcade.Body.prototype = {
}
// Adjust the sprite based on all of the above, so the x/y coords will be correct going into the State update
this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width);
this.sprite.y = this.y - this.offset.y + (this.sprite.anchor.y * this.height);
// this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width);
// this.sprite.y = this.y - this.offset.y + (this.sprite.anchor.y * this.height);
// this.sprite.x = this.x;
// this.sprite.y = this.y;
if (this.allowRotation)
{
this.sprite.angle = this.rotation;
// this.sprite.angle = this.rotation;
}
},