sauravtom Posted February 27, 2014 Share Posted February 27, 2014 I want to move a text object ,this.option1 = game.add.group();this.option1 = this.game.add.text(width-200, 20, "Option 1", { font: "30px Arial", fill: "#ffffff" });this.option1.velocity.x = -200;But it throws a TypeError saying Uncaught TypeError: Cannot set property 'x' of undefined Link to comment Share on other sites More sharing options...
rich Posted February 27, 2014 Share Posted February 27, 2014 Text objects don't have physics bodies, hence why you can't set velocity on them, sorry. Link to comment Share on other sites More sharing options...
jflowers45 Posted February 27, 2014 Share Posted February 27, 2014 Hi sauravtom, Just in case you don't already know these other ways of moving text, you don't have to make them physics bodies, you can use a tween or you can use the update function Here is a simple example http://www.flashysubstance.com/phaserTest/phaserTextMove/ Link to comment Share on other sites More sharing options...
tberend Posted March 16, 2015 Share Posted March 16, 2015 function create () { mytext = game.add.text(10, 500, 'text', { font: "16px Arial", fill: "#FFFF00" })} function update() { mytext.position.y = mytext.position.y-1; // up 1 pixel } nicola 1 Link to comment Share on other sites More sharing options...
rich Posted March 16, 2015 Share Posted March 16, 2015 Please don't get into the habbit of accessing 'position' directly, it can often skip over getter/setter actions. Just do:myText.x = 100;myText.y = 200;Or whatever. Link to comment Share on other sites More sharing options...
Recommended Posts