dthrasher90 Posted February 27, 2017 Report Share Posted February 27, 2017 Hey guys, which method do I use if I have an object set at location (x,y) and I want him to move from that spot to 50 px along the y axis? Quote Link to comment Share on other sites More sharing options...
Rydez Posted February 27, 2017 Report Share Posted February 27, 2017 Aloha! What first comes to mind: myObject.y = 50; But, really, there's many answers to this question. Perhaps you want 50px from the original spot rather than "50 px along the y axis", in that case you might prefer: myObject.y += 50; // or myObject.y -= 50; Or, maybe you have something else in mind. I think this link will be helpful: https://phaser.io/examples/v2/sprites/move-a-sprite Quote Link to comment Share on other sites More sharing options...
dthrasher90 Posted February 27, 2017 Author Report Share Posted February 27, 2017 Which function do those go in, the create? Quote Link to comment Share on other sites More sharing options...
Rydez Posted February 27, 2017 Report Share Posted February 27, 2017 I think I need a better understanding of what you're trying to do in order to say which function. But, probably in the update function. Do you see the update function in the link? Quote Link to comment Share on other sites More sharing options...
dthrasher90 Posted February 27, 2017 Author Report Share Posted February 27, 2017 So Im trying to create a football game. I m just trying to see if I can get the guys moving on the field. my goal is to try to get all this code reusable so i dont have to copy/paste eveything for every person. I just started playing around with this today. The object is you cilck on a play and the computer moves the pieces, base on your players abilities, more rpg, less playstation. function create () { game.physics.startSystem(Phaser.Physics.ARCADE); var field = game.add.sprite(game.world.centerX, game.world.centerY, 'field'); field.scale.setTo(2.75); field.anchor.setTo(0.5); var wr1 = game.add.sprite(100,200, 'wr1'); wr1.scale.setTo(0.5); // wr1.animations.add('run'); // wr1.animations.play('run', 10, true); game.physics.arcade.enable(wr1); var wr2 = game.add.sprite(100, 250, 'wr2'); wr2.scale.setTo(0.5); // wr2.animations.add('run', 10, true); // // game.physics.arcade.enable(wr2); // wr2.animations.add('run'); // wr2.animations.play('run', 150, true); // game.physics.arcade.moveToXY(wr2, 10,50); } Quote Link to comment Share on other sites More sharing options...
dthrasher90 Posted February 27, 2017 Author Report Share Posted February 27, 2017 I got it figured out the tween is what I am looking for 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.