Store position

Get help using Construct 2

Post » Thu Nov 29, 2012 3:58 pm

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. :)
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Thu Nov 29, 2012 4:12 pm

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 Jayjay2012-11-29 16:14:54
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu Nov 29, 2012 4:56 pm

That is close man thanks, instead of destroying though, I want the sprites to move back to their origional position.
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Thu Nov 29, 2012 4:59 pm

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)
B
40
S
12
G
7
Posts: 603
Reputation: 7,656


Return to How do I....?

Who is online

Users browsing this forum: Renfd, supreme676 and 27 guests