[solved] How do I get instance properties

Just started using Construct 2? Post your questions here

Post » Sun Apr 20, 2014 1:52 pm

Hello,
So here is the problem, I've got multiple instances of a platform objects (called platform, duh).
And I'd like to resize one of those platforms every x seconds. I understand the event system, but how can I get and modify the x, and y position of one specific instance? I thought there will be something like this for instance:
System->every 3 seconds->platform.[UID number or instance number]-> set x to platform.[UID number or instance number].X+100
But I dont find the right grammar.... There has to be something like that.

Thanks for reading and helping, I'm sure it's a noob question, but I am drowning in a sea of documentations and tutorials which seem to never need that function.

edit: do I have to create my own ID instance variable and do something like system->every x seconds->platforms->if ID_instance_variable == y -> etc ?
Last edited by Aramir on Sun Apr 20, 2014 4:10 pm, edited 1 time in total.
B
4
Posts: 4
Reputation: 208

Post » Sun Apr 20, 2014 3:07 pm

You can assign different variable values to different instances in the editor, and you can pick that instance by comparing that variable's value at runtime.
Image ImageImage
B
169
S
50
G
173
Posts: 8,319
Reputation: 110,282

Post » Sun Apr 20, 2014 3:53 pm

Thanks again for answering, but
I'm trying to create a "procedural run and jump platform" game (with some subtleties, in short, platforms will be alterable).
So I'd like to know how I can automate the assignement of an "ID variable". For now I'd like to be able to create new platform every 3 seconds with a "ID variable".
Of course I manage to create a new platform with the system->every x seconds->system->createobject, but then I can't set the "ID variable".
So I'm searching also over the platform->OnCreated event because it sounds like a "java constructor" so the answer should be near by. But I don't find it :/
Any ideas ?

EDIT: currently I'm trying to work it out with a global variable "platformNumber" which I increment every second, and use in the declaration of the "ID variable". But it does'nt feel clean if you what I mean.
Last edited by Aramir on Sun Apr 20, 2014 4:00 pm, edited 1 time in total.
B
4
Posts: 4
Reputation: 208

Post » Sun Apr 20, 2014 3:58 pm

When an object is created it is picked, and can be referenced within the tier it was created in.
So set the variable there.
Image ImageImage
B
169
S
50
G
173
Posts: 8,319
Reputation: 110,282

Post » Sun Apr 20, 2014 4:09 pm

Oo, ok thanks I didn't know that. It's not really intuitive but hey, if it helps me I'm not gonna b*tch about that.
Thanks a lot, you spared me troubles.
B
4
Posts: 4
Reputation: 208


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests