strange: x,y position after "create object"

Get help using Construct 2

Post » Mon Jun 17, 2013 6:52 pm


I put all required instances outside of the layout and use the system action: "create object" "on start of layout" (on a layer at a position x,y) to assign the position to the instances in the game.

Strangely, if I request the position then, the instances still have x,y from outside the layout and not the new position I've assigned?!

Is this a bug or do I have an error in reasoning?

Thanks a lot!
B
3
Posts: 6
Reputation: 185

Post » Mon Jun 17, 2013 6:58 pm

Capx would help a lot...
B
16
S
5
G
4
Posts: 74
Reputation: 3,301

Post » Mon Jun 17, 2013 7:17 pm

If you have lots of instances, an expression can only return one value, so it has to pick one of your instances and return the x/y value for that. If you pick an instance in a condition, in that event the expressions will return the value for the first picked instance. If no instances are picked, the engine uses the first instance, which is probably the one outside your layout.
Scirra Founder
B
383
S
225
G
86
Posts: 24,134
Reputation: 190,591

Post » Mon Jun 17, 2013 7:19 pm

the instance outside of the layout is still there, and unless told otherwise the system will pick instance 0 (the first created)

fix by destroy outside layout or add another condition to ensure its picking the onscreen instance...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Mon Jun 17, 2013 7:24 pm

Thanks a lot!
B
3
Posts: 6
Reputation: 185

Post » Mon Jun 17, 2013 7:24 pm

Destroy your sprites on start of layout.
Should do the trick



B
28
S
6
G
2
Posts: 86
Reputation: 3,267

Post » Mon Jun 17, 2013 7:31 pm

destroying the sprites on start of layout helped! thanks!

B
3
Posts: 6
Reputation: 185


Return to How do I....?

Who is online

Users browsing this forum: bangoo and 9 guests