Sprite moving/following another sprite

This student created a game and we just can’t figure out how to do the last thing. He is wanting the laser that is moving to the left across the screen to follow the spaceship and move up and down with the spaceship instead of always just looping to the exact same spot. Basically, he wants the laser to follow or move along with the spaceship.
Any advice?

@sarah.dudley,

It kind of depends on whether he wants the laser to ALWAYS follow the spaceship or only launch from the spaceship and then go straight (until the next time it launches).

Either way, though, he may want to change the y coordinate of the laser (laser4.y) to equal the y value of the spaceship (player.y) rather than always being the same y coordinate. If he does it every time the laser regenerates, it will appear to come from the spaceship. If he puts an assignment statement inside the draw loop setting the y value of the laser equal to the y value of the spaceship, it will be a “smart guided laser” that always follows the spaceship.

Hope that helps!

Mike

1 Like