HammerBro's Recent Forum Activity

  • Brilliant, thanks! Now that you mention it, it does say that on the sourceforge.net/apps/mediawiki/construct/index.php section of the Wiki (not sure how I missed it).

    As a side note, if multiple Sprites are created in the same script, SOL.Sprite only refers to the most recently created one. Not that this is a problem.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, folks. I've used Construct for a couple of one-month game jams in the past, and having come from a Click background taken quite nicely to it. It recently caught my eye when I arbitrarily decided I'd like to make some kind of game in Python -- to my surprise, Construct supported Python (2) scripting and for the most part, it's done exactly what I'd expect it to.

    But I'm having trouble referencing an object just created in the same event. This seems like a very important thing to be able to do, since I'll want to create objects programmatically and change a bunch of their properties immediately.

    I've got an s000.tinyupload.com which demonstrates what I'm trying. Basically, within an event I've got a script, and I'd like that script to create a Sprite object and then tell me how many sprites exist. The script has:

          # Convenient random number generator

          from random import randint

          # Create a new Sprite object in a random position

          System.Create("Sprite", 1, randint(640), randint(480))

          # Count how many objects now exist

          i = 0

          for aSprite in Sprite:

                i = i + 1

          # Display how many objects were counted

          System.MessageBox(i, "Count", 0, 0)

    Running this, the for loop is always one object behind; it never includes the Sprite created earlier in the script. So my question is, within a single script sheet, how do I create an object and then immediately reference it?

HammerBro's avatar

HammerBro

Member since 9 Feb, 2013

None one is following HammerBro yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies