i3Designer Posted August 9, 2014 Share Posted August 9, 2014 create: function(){ this.creaNemici(); }, creaNemici: function(){ this.nemico = game.add.sprite(-100,20,'nemico'); this.nemico.anchor.setTo(0.5,0.5); game.physics.enable(this.nemico, Phaser.Physics.ARCADE); }, update: function(){ game.add.tween(this.nemico).to( { x:game.world.centerX,y:game.world.centerY }, 1300,Phaser.Easing.Linear.None, true); }, I have a problem with the tween. I create an image and want it follows the position of an image. To test I set that the enemy has to go in the center of the world, I have done as above by removing the piece of code that was not interested. But I start, the game show two images. PS: In localhost I see two pictures, but if I do the screenshot, you can not see. is the render? Link to comment Share on other sites More sharing options...
eguneys Posted August 9, 2014 Share Posted August 9, 2014 don't add tween in the update method, update method gets called on every frame, like 60 times per second. add your tween in create method. Link to comment Share on other sites More sharing options...
i3Designer Posted August 9, 2014 Author Share Posted August 9, 2014 don't add tween in the update method, update method gets called on every frame, like 60 times per second. add your tween in create method.But I want to do that the enemy is always running towards the object Link to comment Share on other sites More sharing options...
i3Designer Posted August 10, 2014 Author Share Posted August 10, 2014 I tried a lot, and I settled with: game.physics.arcade.moveToObject Link to comment Share on other sites More sharing options...
Recommended Posts