Z's learning Construct thread

This forum is currently in read-only mode.
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Objects are not fully created until the end of the event sheet. You only have been the event that the object was created in to modify anything about it until the next tick.

    event one


    • Create object sprite
    • set sprite color filter

    event two

    • set sprite angle

    In this example, the sprite would have its color filter set but its angle would not be set until the next tick.

  • Okay, well then I'm going to have to find a way to make it happen after the first tick, because I need to color filter several objects that are created at once, based on each player's number.

    As you can see with the example below, only one of the sprites is being colored.


    What I'm doing is, upon network connection, each client that connects to the server is given a unique number. After that, a random start position on the map is chosen for that player, and a starting building and harvesters are created. Rather than have to draw each color of each unit and building, I drew them all white, with the intention of using the color filter to apply colors after creation.

    Any ideas?

    EDIT: I made a 'only trigger once' event, based on whether or not the player has a number assigned yet, and moved it above the section that creates the sprites, so that it triggers on the second tick after creation. It works, but I'd still like to get that code out of the main loop.



  • In your example only the last sprite is getting colored because only the most recently created sprite gets picked. So the trick is to assign a color filter as the sprites are created.

    Here are two different ways to do it:

    + Button: On Button clicked
    -> System: Create object Sprite on layer 1 at (100, 100)
    -> Sprite: Set filter to cyan
    -> System: Create object Sprite on layer 1 at (250, 100)
    -> Sprite: Set filter to cyan
    -> System: Create object Sprite on layer 1 at (400, 100)
    -> Sprite: Set filter to cyan
    [code:3bh1xu44]+ Button: On Button clicked
    + System: For "" from 1 to 3
    -> System: Create object Sprite on layer 1 at ({100, 250, 400}@LoopIndex, 100)
    -> Sprite: Set filter to cyan[/code:3bh1xu44]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, that I can handle.

    Next, I've got some python script for network communication directly after an object's creation. The code runs, but the same problem seems to be coming up here now, too. The variables for the object don't exist yet because the object was just brought into existence.

    I need to transmit the x/y location, its uid, and some private variables about its creation. Rawr. This is being more difficult than I expected.

    EDIT: I can set a text box to show the value of the created object's UID, but the python script throws an error on any variable I try to access about it until the next tick. Hmm..

    EDIT2: It appears that the python script is running before the other actions in the event. I set the value of a text box to the x/y location of the created object. After that I have a python script trying to read those values. When run, the python error pops up before the text box shows the x/y locations.

    Here's an example CAP to show what I mean: http://dl.dropbox.com/u/6365460/pythonproblem.cap

    If this is a limitation of the interface, I can live with that, I just need to figure out a reasonable work around. I had written down 28 different kinds of units I planned on making, so hopefully whatever it is won't be too long or complicated.

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