How do I change between objects' IID

Get help using Construct 2

Post » Wed Jul 08, 2015 8:22 am

I add an object to the layout then copy and paste it a few times to create the instances.

I want to be able to switch from one IID to another through "Action"... but it seems the only way to pick the IID is through System Event. I dont want to use UID as i know my IID's.

I have created a Function with actions

I want the Actions to pick the object with IID 1 then perform actions on that instance

then pick IID 2 and perform actions on that instance.

I'm not sure if i have the structure wrong but the only way i see to change or pick the IID is in a system event but all the system events in that Function happen all at once and not in sequence.

Im finding i have to create a new separate Function each time i want to change the selected IID.
B
3
Posts: 9
Reputation: 193

Post » Wed Jul 08, 2015 8:49 am

You can try:

On event/function/condition: sprite(1) action 'sprite with IID=1 action
sprite(3) action 'sprite with IID=3 action and so on
Image Image
B
25
S
14
G
137
Posts: 876
Reputation: 71,510

Post » Wed Jul 08, 2015 5:59 pm

Im sorry but either i dont understand that or your not understanding my question.
I can't add a condition to the action, only the Function Event. I want the action to change the IID.

In general :

Function ( On "Testing")
Action = choose sprite with IID 1
Action = rotate the sprite selected above 45 degrees
Action = wait 5 seconds
Action = choose sprite with IID 2
Action = rotate this particular sprite counter clock wise

"I'm trying to apply actions to each of the sprites with a certain IID separately "


The way i accomplish that now is :

"choose sprite with IID 1" is located in another Function then called on from "Testing"
It is a System Event and will apply when that function is called then all the actions will apply to that IID as well.

I dont know if this is the only way but id rather have all the particular code in 1 function.
B
3
Posts: 9
Reputation: 193

Post » Wed Jul 08, 2015 6:44 pm

Sorry, I misread your post...

You want something like this?
Image Image
B
25
S
14
G
137
Posts: 876
Reputation: 71,510

Post » Wed Jul 08, 2015 7:09 pm

You can add a sub event to the function to choose that IID, but I don't think choosing something by IID is available as an action.
B
11
S
2
G
1
Posts: 79
Reputation: 842

Post » Wed Jul 08, 2015 7:31 pm

NP, thanks for that example

that is essentially what i had already started with but also mentioned that the problem is that all the "System" Events are occurring at the same time when the function is called or the event occurs.

So in your example when the Enter key is pressed each sprite does rotate separately and that is what i already had but not desired outcome.
Problem is i need 1 to complete before the next is started such as putting in the "Wait 5 seconds".
I currently have each action in a new function so that i can have it wait before calling the next function. But the code for it grows cumbersome.

So in your example i would want to rotate the first sprite then wait 1 second before the next sprite is rotated and so on.
If i had 100 sprites for example that would mean 100 calls to a function to perform some actions then another 100 functions to call if i want to perform different actions. So thats my dilemma

I couldn't get it to work in sub events either.
B
3
Posts: 9
Reputation: 193

Post » Wed Jul 08, 2015 8:52 pm

@kcmd

I updated the link with another layout which uses function (for all sprite with the same delayed action)
Image Image
B
25
S
14
G
137
Posts: 876
Reputation: 71,510

Post » Thu Jul 09, 2015 3:40 am

Hey that one works pretty good.

Thanks for your time.
B
3
Posts: 9
Reputation: 193


Return to How do I....?

Who is online

Users browsing this forum: ametueraspirant, dand, mickclarke and 27 guests