Setting IIDs based on IVs

Get help using Construct 2

Post » Sun Sep 02, 2012 11:45 pm

I'm sorry, I'm a little out of it and despite reading a good deal on IIDs in the manual and throughout the forums, today just isn't the day for my brain to be especially adaptive.

I'm trying to set the IIDs of an object's instances based on its x-coordinates.

E.g.

Object1 X=60 ---> set IID to 1

Object1 X=150 --> set IID to 2

and then..

Object1 IID=1 --> set animation frame to 0

Object IID=2 ---> set animation frame to 1

et cetera.

I understand I might need to use instance variables and/or [though hopefully not] nth instances, as referred to in the manual:

"Pick Nth instance
Pick the instance at a given place in the internal list of picked objects. This is most useful used in sub-events to act on separate instances. For example, in a "Sprite collided with Sprite" event, Pick 0th instance and Pick 1st instance can be used to act on each instance involved in the collision separately.

If all objects are currently picked, this condition can also be used to pick an object by its index ID (IID). For more information, see common features."

Anyways, I'm going to go be active for a bit in an attempt to rejuvenate myself. Any assistance here would be appreciated.

Thank you!
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Sep 03, 2012 12:06 am

Hey Teahouse,

To quote Ashley in a prev post,

"IIDs are not constant - they change as you destroy and create objects, so you can never be certain that an IID refers to a specific instance.

You probably want to use UIDs instead, which permanently refer to a single instance."

But to take a stab from a different angle you could try to set variables for the objects once they pass a point by laying down invis sprites and then using "Object is overlapping Sprite - Set animation frame to X".

ImageImage
B
73
S
16
G
6
Posts: 1,038
Reputation: 10,473

Post » Mon Sep 03, 2012 3:02 am

That's an interesting idea, thank you GenkiGenga. Unfortunately, I don't think it will work, as I suspect that setting animation frame to X under those circumstances will lead to all of said 'objects' instances changing frame in response to that event.

But I will give it a shot and report back!

Also, looking forward to checking out your portfolio site!
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Sep 03, 2012 3:03 am

The easiest way to fix this, I think, is to simply import each frame as a separate sprite. I was just hoping to avoid that.
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Sep 03, 2012 3:16 am

Outstanding! Your recommendation works!

I clearly have a good bit more to learn with regards to interactive elements in C2.

Thanks again!
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Sep 03, 2012 8:24 am

No worries!

By the sounds of things you'll be catching up pretty quickly. I'll keep you updated about the site ;)
ImageImage
B
73
S
16
G
6
Posts: 1,038
Reputation: 10,473


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests