accessing newly instantiated Widgets

This forum is currently in read-only mode.
  • 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)

  • With the the latest version of Construct(0.99.93) you can reference a newly created object in python like so:

    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]
    

    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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for your help. That is precisely what I was looking for.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)