0

I am working on trying to change the anchor point of a sprite.

Most of the examples I have seen look something like this:

this.asset.anchor.setTo(0.5, 0.5);

But I am not really clear on how the this keyword is used in javascript.

How do I adjust the anchor point of a sprite?

MamaWalter
  • 2,073
  • 1
  • 18
  • 27
SPKEZ
  • 23
  • 2

1 Answers1

0

For more information about the "this" keyword in JavaScript, I encourage you to have a look at the questions that deal about this specific problem, such as this one : How does the "this" keyword work?

However, from the Phaser point of view, the anchor point is the anchor of Phaser Sprite or a Phaser Image, so to change the anchor point of any sprite, change it after the sprite has been created :

var sprite = game.add.sprite(10,10,''); // and then sprite.anchor.set(0.5); Also your example was not super clear, "this.assets" isn't super explicit in my opinion as a sprite doesn't necessarily come from an asset, which example were you looking at ?

Community
  • 1
  • 1
  • Oh gosh... It was long enough ago now that I don't remember which example it was. Sorry... – SPKEZ Jan 22 '15 at 23:32