Jump to content

how do i define a default anchor on phaser?


sombriks
 Share

Recommended Posts

Hello all,

 

i'm defining my sprites like this:

var e1p2 = game.add.sprite(244, 583, "folha128x128", 4)// e1p2.anchor.set(0.5, 0.5);

However i have several lines like that.

 

where could i define a default anchor on phaser?

 

Thanks in advance.

Link to comment
Share on other sites

1. The hard way - create an object constructor and use :

this.anchor.setTo(0.5, 0.5);

For every new instance created the anchor will be (0.5, 0.5);

 

2. The easy way - put all your sprites in a group :

var brands = game.add.group();brands.create (100, 50, 'Samsung');brands.create (150, 100, 'Apple');brands.create (200, 150, 'LG');brands.children.forEach(function(brands){             brands.anchor.setTo(0.5, 0.5);});
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...