为什么addPolygon改变位置图像 - phaser.js

时间:2015-05-31 12:10:28

标签: javascript phaser-framework

使用addPolygon时遇到问题。多边形改变位置图像。当我打开调试时,我看到图像,并在中心绘制新的形状。第二个问题我现在不知道为什么图像和形状Polygon是不同的。怎么解决这个问题?我使用addRectangle时没有看到问题。图像和新形状是图块70px x 70px的核心。

function create() {
...
groups.tile = game.add.group();
groups.tile.enableBody = true;
groups.tile.enableBodyDebug = true;
groups.tile.physicsBodyType = Phaser.Physics.P2JS;
groups.tile.collideWorldBounds = false;
...

var obj = groups.tile.create((x * map.width) - (map.width / 2), (y * map.height) - (map.height / 2), spriteName, numberTile);
obj.body.static = true;
obj.body.fixedRotation = true;
obj.body.collideWorldBounds = true;
obj.body.clearShapes();

var myPolygonArray= [ [0,0], [0,70], [70,70], [70,46], [25,46],  [25,0]];
obj.body.addPolygon({}, myPolygonArray);
}

示例:

a)enter image description here b)enter image description here c)enter image description here

如果有人发现它有任何解决方案吗?

0 个答案:

没有答案