Meowts Posted October 10, 2014 Report Share Posted October 10, 2014 Hey, Real simple case: draggable popup window with text.var popup = this.game.add.sprite(coordinates[0], coordinates[1], this.popupSprite);popup.anchor.x = 0.5;popup.anchor.y = 0.5;var t = this.game.add.text(popup.x-110, popup.y-50, msg, this.msgStyle); popup.addChild(t);popup.inputEnabled = true;popup.input.enableDrag(false);Problem: After calling addChild, it ends up rendering the text way off to a seemingly random coordinate, sometimes even off the screen. The text does move with the popup window however. I played around with Groups to handle this, but the problem is that the text does not move with the popup window, even though they are in a group. Any suggestions on how to handle this? Quote Link to comment Share on other sites More sharing options...
lukaszwojciak Posted October 10, 2014 Report Share Posted October 10, 2014 You're adding the text to the popup but you also offset it with the text coordinates - which isn't a great solution also because the popup has an anchor.x/y = 0.5. var t = this.game.add.text(popup.x-110, popup.y-50, msg, this.msgStyle); popup.addChild(t); Just try: var t = this.game.add.text(0,0,msg,this.msgStyle; popup.addChild(t);t.anchor.setTo(0.5, 0.5); And see how that works. Quote Link to comment Share on other sites More sharing options...
Meowts Posted October 10, 2014 Author Report Share Posted October 10, 2014 Works like a charm, thanks so much! I hadn't considered that the text would inherit the popup's coordinates... like some sort of, child... hahaha -.- Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.