How do I add an instance with iid=0?

Get help using Construct 2

Post » Fri Jun 24, 2016 7:33 pm

Dear, excuse me for having IID like 11.445, i know that means that i should sit silenced in my corner.
But as a beginner, i think i have to right to ask you a beginner question.

How is this 'hack' different from running trough the list in the other way ... like

For "index" from sprite.count to 0
pick nth loopindex("index")

or

for each (ordered by sprite.iid, ascending)

or
for last one
pick all
pick nth (-1)

or any expression like
pick all
sprite(sprite.count - 44).x

As in my beginners opinion, the difference only seems a warning about future support.
B
33
S
18
G
27
Posts: 2,447
Reputation: 20,358

Post » Fri Jun 24, 2016 7:59 pm

R0J0hound wrote:That function is run when a top level event is reached, so the objects get destroyed and new objects added to the instance lists then. Without the hack can you access new objects by iid immediately after? If that works then something else is done behind the scenes to make that possible. Maybe instead of that second loop use "type.stale_iids = true;", so new iids are generated by the runtime instead. Untested but it seems to do that with families.

Without the hack, Sprite.IID will return the last IID (the object created). Sprite(N).IID will always return 0 (even if you do a Pick All sub-event).
Without the hack, you can pick Nth instance after creating one (in a sub-event), as long as you do a Pick All to select all instances.

With the Hack, Sprite.IID will return wrong IID after creating a new object at front. It returns the IID as if it is at the back. However if I add to CreateObject in system.js:
Code: Select all
if( window["createAtFront"])
            inst.iid = 0;

then it returns 0.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Fri Jun 24, 2016 8:14 pm

Seems like Pick All will exclude any newly created Objects, with or without the hack. A bug?
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Previous

Return to How do I....?

Who is online

Users browsing this forum: Demkamen, Yahoo [Bot] and 13 guests