kstamatov85 Posted May 31, 2015 Share Posted May 31, 2015 Hi guys, I have a problem with setting the anchor position of text object that have no refference for.var profileData = this.add.group();for(x in GH.userProfileData){ profileData.add(this.game.make.text(0, pos, GH.lang.userProfileLabel[x]+': ', GH.font.labelFont)); profileData.add(this.game.make.text(200, pos, GH.userProfileData[x].toString(), GH.font.valueFont)); pos+=50; }I try chaining .anchor(1,0) to first text, but it did not work and unfortunately couldn't found anything about that issue.Anybody know how to solve that issue? Link to comment Share on other sites More sharing options...
Tom Atom Posted May 31, 2015 Share Posted May 31, 2015 Hi, instead of: .anchor(1, 0);try:.anchor.setTo(1, 0); Link to comment Share on other sites More sharing options...
kstamatov85 Posted June 1, 2015 Author Share Posted June 1, 2015 I try that, because it was most obvious, but phaser returns "TypeError: a.setStageReference is not a function". Anyway I found a workaround, but it is not as elegant as I would like to be.var textObj = {};for(x in GH.userProfileData){ textObj.x = this.add.text(200, pos, GH.lang.userProfileLabel[x]+': ', GH.font.labelFont); textObj.x.anchor.setTo(1, 0); };I guess there should be a phaser way to do that more clean Link to comment Share on other sites More sharing options...
Tom Atom Posted June 2, 2015 Share Posted June 2, 2015 anchor is not function - it is object. This is reason, why you got error when calling it like "anchor()" with parenthesis. It is Phaser.Point object, that has x and y ... and you can change it like: .anchor.x = ... or both at once like anchor.set(x, y) or anchor.setTo(x, y). Link to comment Share on other sites More sharing options...
kstamatov85 Posted June 4, 2015 Author Share Posted June 4, 2015 Tom, how to apply those in my code? Could you use the example above and show us.Thanks Link to comment Share on other sites More sharing options...
Recommended Posts