scope of copied objects on diff. layouts

Discussion and feedback on Construct 2

Post » Tue Aug 28, 2012 9:06 pm

I have a game which was created on portrait. I then copied the layout (and all its layers and objects), named it landscape, and resized and re-arranged some of the items.

How does construct 2 reference copies of the same object on the same layout, and on different layouts?

Is there any way to reference the object on the current layout (e.g.

[CODE]
craete object CurrentLayout.SpriteA
[/CODE]

Otherwise, how will you know which of the two objects of the same name it will pick?

In game, the player can switch between portrait and landscape any time (e.g. by resizing browser, or turning phone/ipad).

I have one event sheet attached to both layouts.

It mostly works, but there are some strange effects.

Sprite A and Sprite B were on layout1, and were copied to Layout2.

In the event sheet, I create new sprite A object, and place it on the layout. If I resize Sprite A in layout 1 before hand, the new size is not reflected when playing in either layout1 (portrait) nor layout2 (landscape) - its in limbo.

However, when I resixe Sprite A copy in layout 2, the new size shows up when playing in both portrait and landscape mode. This is odd.

However, if I resize sprite B, which was sitting on the layout (not created dynamically) 1, it only affects layout one, and the same for layout 2.

Other strange effects are that I have a version, status and FPS text field which are all updated by the single event sheet each tick. However, only two of the three text fields work - I cant get the version to work any more. Even though I am updating it, its not getting updated in either layout.

B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Tue Aug 28, 2012 9:34 pm

Each layout is independant, when you switch layout the only thing that c2 keeps is global variables and objects, everything else is destroyed when you leave a layout. New instances are created when you enter the other layout.
The event sheet just uses the object there's on each layout as if there was only one layout.Yann2012-08-28 21:35:15
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Aug 28, 2012 9:43 pm

hmm. That sounds logical, but layout 1 defilietly is creating objects from layout 2. e.g. If I have spriteA on layout 1 and the same object copy on layout2, then radically change the size of spriteA on layout1 to be huge, and the spriteA copy on layout2 to be tiny, when the object gets created on layout1 its using the tiny version from layout2. Layout2 uses the tiny version too.



B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Wed Aug 29, 2012 7:24 am

Maybe it's using the default size of the texture.
To be sure share the capx
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests