Javascript 移相器:从身体上换锚?

Javascript 移相器:从身体上换锚?,javascript,html,phaser-framework,Javascript,Html,Phaser Framework,在移相器中,是否可以将锚从主体更改为中心,就像从对象更改为中心一样 这不起作用: Sprite.body.anchor.x=0.5 你应该写: 雪碧。锚。设定到(x,y) 或: 雪碧。锚。套装(x) 如果您希望在相同的x&y坐标系中锚定您的精灵,即:sprite.anchor.set(0.5);将锚点水平和垂直放置在精灵的正中间 这在最新版本的Phaser中应该可以正常工作。您应该写: 雪碧。锚。设定到(x,y) 或: 雪碧。锚。套装(x) 如果您希望在相同的x&y坐标系中锚定您的精灵,即:sp

在移相器中,是否可以将锚从主体更改为中心,就像从对象更改为中心一样

这不起作用:

Sprite.body.anchor.x=0.5

你应该写:

雪碧。锚。设定到(x,y)

或:

雪碧。锚。套装(x)

如果您希望在相同的x&y坐标系中锚定您的精灵,即:sprite.anchor.set(0.5);将锚点水平和垂直放置在精灵的正中间

这在最新版本的Phaser中应该可以正常工作。

您应该写:

雪碧。锚。设定到(x,y)

或:

雪碧。锚。套装(x)

如果您希望在相同的x&y坐标系中锚定您的精灵,即:sprite.anchor.set(0.5);将锚点水平和垂直放置在精灵的正中间


这在最新版本的Phaser中应该可以正常工作。

这里有一些选项可以更改精灵的锚定点:

// Set the anchor point to the top left of the sprite (default value)
   this.sprite.anchor.setTo(0, 0);

// Set the anchor point to the top right of the sprite
   this.sprite.anchor.setTo(1, 0);

// Set the anchor point to the bottom left of the sprite
   this.sprite.anchor.setTo(0, 1);

// Set the anchor point to the bottom right of the sprite
   this.sprite.anchor.setTo(1, 1);

// Set the anchor point to the center of the sprite
   this.sprite.anchor.setTo(0.5,0.5)

这里有一些选项可以更改精灵的定位点:

// Set the anchor point to the top left of the sprite (default value)
   this.sprite.anchor.setTo(0, 0);

// Set the anchor point to the top right of the sprite
   this.sprite.anchor.setTo(1, 0);

// Set the anchor point to the bottom left of the sprite
   this.sprite.anchor.setTo(0, 1);

// Set the anchor point to the bottom right of the sprite
   this.sprite.anchor.setTo(1, 1);

// Set the anchor point to the center of the sprite
   this.sprite.anchor.setTo(0.5,0.5)

我不明白为什么你需要从身体开始,身体采取精灵的姿势,我的意思是身体将适合精灵,但我想让碰撞发生在另一个姿势,然后是精灵,你知道这样做的可能性吗?举个例子:我有一个球员,当他从左向右行走时,他的脚上有一个锚。但是当我跳的时候,我想把锚从身体换到角色的中间。我不这么认为,但是还有其他方法,比如制作空的精灵,设置它的身体,然后把它附加到x上的另一个精灵上,你想要相对于精灵,但为什么不使用physic editor软件为整个玩家制作复杂的身体,我不明白为什么你需要从身体开始,身体采取精灵的位置,我的意思是身体将适合精灵,但我想在另一个位置进行碰撞,然后是精灵你知道这样做的可能性吗?举个例子:我有一个球员,当他从左向右行走时,他的脚上有一个锚。但是当我跳起时,我想把锚从身体改到角色的中间。我不这么认为,但是还有其他方法,比如制作空的精灵,设置它的身体,然后将它附加到x,y上的另一个精灵。你想要相对于精灵,但是为什么不使用physic editor软件为整个玩家制作复杂的身体呢