accessing newly instantiated Widgets

For questions about using Classic.

Post » Fri Jan 14, 2011 4:38 am

What method, if any, is the correct way to get a reference to a newly instantiated object?

I have an object called Widget, which I want to create many instantiations of using Python. After creating a new Widget, I want to access it so I can modify its properties. However, I don't know how to get a reference to the new Widget.
I thought System.CreateObjectByName() would return a reference to the new Widget, but it doesn't.
I thought that I could get the new Widget by accessing the last element of the Widget[] array, but it seems like the array doesn't add the new objects right away. (maybe it waits until the next frame?)

Here is a .cap showing my failed attempts.
Download

(I'm using Construct version 0.99.96, if that's relevant)
B
1
G
1
Posts: 6
Reputation: 437

Post » Fri Jan 14, 2011 9:12 am

[quote="R0j0hound":27wbcj3x]With the the latest version of Construct(0.99.93) you can reference a newly created object in python like so:

[code:27wbcj3x]System.Create('Sprite',1,0,0)
objRef=SOL.Sprite #this gets the reference of the new Sprite.

objRef.x=400
objRef.y=300
objRef.angle=30
objRef.skewy=20[/code:27wbcj3x][/quote:27wbcj3x]

My logic tells me this is what you're looking for, hopefully. Not much of a python user myself.

And welcome to the community magicalblender!
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Jan 14, 2011 10:31 am

Thanks for your help. That is precisely what I was looking for.
B
1
G
1
Posts: 6
Reputation: 437


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests