mirror of
https://github.com/wassname/phaser.git
synced 2026-07-25 13:20:14 +08:00
Edge points in and working.
This commit is contained in:
+16
-12
@@ -69,11 +69,7 @@
|
||||
br = points[2];
|
||||
bl = points[3];
|
||||
|
||||
s.anchor.setTo(0, 0);
|
||||
s.angle = 5;
|
||||
|
||||
// get the distance between top-left and bottom-right
|
||||
// distance = Phaser.Math.distance(0,0,s.width,s.height);
|
||||
s.anchor.setTo(2, 0.5);
|
||||
|
||||
// PIXI worldTransform order:
|
||||
|
||||
@@ -94,10 +90,10 @@
|
||||
|
||||
s.angle += 0.5;
|
||||
|
||||
if (s.scale.x < 2)
|
||||
if (s.scale.x > -2)
|
||||
{
|
||||
s.scale.x += 0.01;
|
||||
s.scale.y += 0.01;
|
||||
s.scale.x -= 0.01;
|
||||
s.scale.y -= 0.01;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,17 +104,23 @@
|
||||
|
||||
// var p1 = getLocalPosition(midpoint.x, midpoint.y, s);
|
||||
|
||||
var offsetX = s.anchor.x * s.width;
|
||||
var offsetY = s.anchor.y * s.height;
|
||||
|
||||
var sx = s.x - offsetX;
|
||||
var sy = s.y - offsetY;
|
||||
|
||||
// top left
|
||||
var p1 = getLocalPosition(s.x, s.y, s);
|
||||
var p1 = getLocalPosition(sx, sy, s);
|
||||
|
||||
// top right
|
||||
var p2 = getLocalPosition(s.x + s.width, s.y, s);
|
||||
var p2 = getLocalPosition(sx + s.width, sy, s);
|
||||
|
||||
// bottom left
|
||||
var p3 = getLocalPosition(s.x, s.y + s.height, s);
|
||||
var p3 = getLocalPosition(sx, sy + s.height, s);
|
||||
|
||||
// bottom right
|
||||
var p4 = getLocalPosition(s.x + s.width, s.y + s.height, s);
|
||||
var p4 = getLocalPosition(sx + s.width, sy + s.height, s);
|
||||
|
||||
p1.add(s.x, s.y);
|
||||
p2.add(s.x, s.y);
|
||||
@@ -139,6 +141,8 @@
|
||||
game.debug.renderText('ty: ' + tr.y, 32, 265);
|
||||
game.debug.renderText('px: ' + p2.x, 32, 280);
|
||||
game.debug.renderText('py: ' + p2.y, 32, 295);
|
||||
game.debug.renderText('ox: ' + offsetX, 32, 350);
|
||||
game.debug.renderText('oy: ' + offsetY, 32, 370);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<!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('mushroom', 'assets/sprites/mana_card.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'mushroom');
|
||||
|
||||
s.anchor.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
s.angle += 0.5;
|
||||
|
||||
if (s.scale.x > -2)
|
||||
{
|
||||
s.scale.x -= 0.01;
|
||||
s.scale.y -= 0.01;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderPoint(s.topLeft, 'rgb(255,0,0)');
|
||||
game.debug.renderPoint(s.topRight, 'rgb(0,255,0)');
|
||||
game.debug.renderPoint(s.bottomLeft, 'rgb(0,0,255)');
|
||||
game.debug.renderPoint(s.bottomRight, 'rgb(255,0,255)');
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user