sauravtom Posted March 2, 2014 Share Posted March 2, 2014 Hi guys, I am back with another noobish question. I have created a text object in my game.this.text1 = this.add.text(63, 50, "Option 1", style);and added some fancy tween animation to it.and now in the update function I want to access its position,console.log(this.text1.x);But it only returns "63" i.e the initial position that I created it at, and not the dynamic position. How can I make it return the real time position of the text object ? /*======================================================================*/I basically wanted to check the position of text to make sure whether it was overlapping with my main character.I went through the docs and I though that maybe I should use the overlap function for this .So I added the following in the update function.this.game.physics.overlap(this.bird, this.text1, this.restart_game, null, this);But sadly that didn't work either. Quote Link to comment Share on other sites More sharing options...
rich Posted March 2, 2014 Share Posted March 2, 2014 Hmm that should work, but it depends how you're tweening it. Try looking at this.text1.position.x/y and see if that differs. sauravtom 1 Quote Link to comment Share on other sites More sharing options...
sauravtom Posted March 2, 2014 Author Share Posted March 2, 2014 Hmm that should work, but it depends how you're tweening it. Try looking at this.text1.position.x/y and see if that differs. @rich, I am tweening the text as follows, var tweenTimeMS=1000*(width/pipe_velocity); var tweenAutoStart=true; var tweenDelay=0; var tweenRepeat=false; var tween1 = this.add.tween(this.text1).to( {x:0}, tweenTimeMS, Phaser.Easing.Linear.In, tweenAutoStart, tweenDelay, tweenRepeat); and upon using this.text1.position.x , I am getting the initial value( 63 ) as before. 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.