Store position

0 favourites
  • 4 posts
From the Asset Store
290 static tiles (32x32 in size) + 2 animations for use in your project!
  • I'm flying with the questions this week, very sorry I'm just constantly hitting walls which are quite easy to break down.

    This is my last for the week:

    I want to store the starting position of a sprite (and its copies) so that when they get displaced I can return them to that position.

    My context is I have a platform made of physics objects (multiple copies of the same sprite) - these sprites can be moved, lets say a ball hits them and they all scatter. What I want to happen is for them to return to their starting position after they've been scattered.

    I promise that's the last cry for help you'll get from me this week forum. :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could instead design your maps with "Spawn" objects that are invisible on startup, and store a private variable "ObjectType" of what they are supposed to represent ingame.

    Then in an event for the start of a layout do a "For each object" loop on each spawn object, add sub-events to check what the value of ObjectType is and then create the respective object at its position (you can also set its angle to the angle of the spawn object).

    Then for replacing the objects, just destroy all game objects and run the Spawn object For loop again <img src="smileys/smiley1.gif" border="0" align="middle" />

  • That is close man thanks, instead of destroying though, I want the sprites to move back to their origional position.

  • Give them local variables for X and Y. Then, when they are created do a for each event that stores their x and y position. Then, whenever you need them to return to their start positions get those numbers and send them back (make sure to fo a for each event)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)