How do I keep the same image object between layouts

Get help using Construct 2

Post » Wed Nov 19, 2014 10:32 pm

How do I keep the same image object in the same place between two layouts ?
I have an image which is located in layout 1 in some position(x,y), when the game goes to another
screen, which is layout 2, I want the same image to be on the same spot regardless of other objects in
the second layout.
Is there a way to do it by an event on layout 1 so it will affect also layout 2, without using the same
event to position the image also in the events sheet for layout 2 ?
For example, like a life bar you see between different screens/levels in a game.
B
5
S
1
Posts: 22
Reputation: 417

Post » Wed Nov 19, 2014 11:01 pm

Hi Zoltar!
Just grab the xpos and ypos while you're in layout 1 and store them in global variables.
Then go to layout 2 and get those variables and use them to position your object there.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 19, 2014 11:15 pm

Is there a way to do it by global array since I have some images, and instead of using multiple global variables I would like to create a global array if it's possible ?
B
5
S
1
Posts: 22
Reputation: 417

Post » Wed Nov 19, 2014 11:25 pm

Have you considered NOT using a different layout, but instead just using the visibility of the layers in a single layout? The visual effect would be the the same as a new layout and all of your objects would already be in the right positions.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Wed Nov 19, 2014 11:58 pm

Yes, I thought about it, the question is if it's the right thing to do and what someone does when we're speaking about
different levels in a game and in each screen you have to keep track of the same images in the same position ?

In my game I have a menu bar with 5 different weapons inside 5 cells, after 2 minutes the game switches to another screen which is the weapons store, so the player can buy/sell his inventory to the store. after clicking on "Done" button the screen switches back to the game with the updated weapons in the same 5 cells which are located in the same spot all the time during game play.
So if for example the player has used all the units of weapon in cell3 than the image of this weapon disappears and cell3 becomes empty which I want to be reflected also in the weapons store where the player can see his inventory like in the game screen.

I thought about using only layers in the same layout, but is it the right thing to do ?
B
5
S
1
Posts: 22
Reputation: 417


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests