nutmix's Forum Posts

  • OK, sussed it. The correct format is:

    "{

        ""c2array"": true,

        ""size"": [75,1,1],

        ""data"":[[[""na""]],[[""st""]],[[""nd""]],[[""rd""]],[[""th""]]]

    }"

    Doesn't seem logical, but I guess thats JS for you!

  • From various posts, I have guessed at the JSON format required to load an array.

    Its for looking up the "th" string, e.g.

    "1" & array.at(1)

    should result in "1st" etc.

    I tried loading it with this string:

    "{

        ""c2array"": true,

        ""size"": [75,0,0],

        ""data"":[1:""st"",2:""nd"",3:""rd"",4:""th""]

    }"

    I also tried this:

    "{

        ""c2array"": true,

        ""size"": [75,1,1],

        ""data"":[[[1:""st"",2:""nd"",3:""rd"",4:""th""]]]

    }"

    and this:

    "{

        ""c2array"": true,

        ""size"": [75,1,1],

        ""data"":[[[""na"",""st"",""nd"",""rd"",""th""]]]

    }"

    and a million other formats.

    The ones which dont throw a runtime error, all print "10", i.e. they get back zero from the array.

    Anyone know the required JSON format to load an array (or dictionary).

    Thanks!

  • I have read the container manual page, but i am struggling to get them to work.

    Firstly, I don't get if I am supposed to take the container object, and add its sub objects, or take each sub object, and add the container object.

    Currently I am doing both, so if A contains B, I add B as the container for A, and A as the container for B. If I only do one, I get unpredictable results.

    What objects are containers? Can any object be a container?

    If I want to take a large group of sub objects which together make up one complete object, can i use containers to only have to anchor one object, rather than individually anchor them all? Previously I did this with pinning, but as pinning can only be set at run time, I end up with lots of code like:

    pin B to A

    pin C to A

    pin D to A

    Etc. Shame this cant be done in the designer.

    What else do containers give you?

    Currently I only know one thing: if you create the container, it creates the sub objects.

    If you select one of the sub object, I could not get it to also select the container, so I use instance variables called MYID, and assign both container and containee the same instance Var at run time. This works, and allows me to select one when the other is selected. Are containers supposed to help with this?

  • LittleStain

    good exmaple. Do you have to destroy the template object like this? I havent done this, which could be why in your third action its affecting mutliple sprites. Or perhaps because my equivalent of Sprite3 is in a family with lots of other copies of Sprite3?

  • This does not seem to work for me. If I create a new ball object for example, then use ball.xx in the action of the same or a sub event, it always acts on all balls, not the one I just created.   As I don't know how to pick the event I just created, I actually do this:

    1) have he ball on a special layer, called "templates"

    2) have a blank layer called "new"

    3) create a new "ball" object on layer "new".

    4) use an event condition where I say ball.isOnLayer("new")

    5) then in the events actions, do this: ball.setLayer("target")

  • This does not seem to work for me. If I create a new ball object for example, then use ball.xx in the action of the same or a sub event, it always acts on all balls, not the one I just created.   As I don't know how to pick the event I just created, I actually do this:

    1) have he ball on a special layer, called "templates"

    2) have a blank layer called "new"

    3) create a new "ball" object on layer "new".

    4) use an event condition where I say ball.isOnLayer("new")

    5) then in the events actions, do this: ball.setLayer("target")

    This seems to work.

  • Ok, my solution did not work. I have tried the following:

    1) Spawning a copy of an existing (off layout) ball object, then using ball->set x etc. in actions in the same event block. This moves all balls, not the one just created.

    1) assigning a intance variable called "justCreated" and set it to 0. Use System->create object to create a new ball. In a sub event, select ball where justCreated = 0, and set it to 1. Do stuff to that ball. This doesnt work as it affects the newly created ball, AND the template/dummy ball which is only there to allow new balls to be created.

    Can anyone point me to a man page, thread, or capx which shows how to pick the object you just created/spawned?

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Perfect! Ill stick with that then - nice.

    Thanks!

  • Er, if you cant create then pick, what is the recommended solution? Create, wait, then pick? That would seem tricky?

  • If I want to create a ball, then do stuff with it (e.g. move it around), that's easy. But If I want to create an instance of say a blue, black or red ball, then do the same stuff with which ever one I just created?

    E.g. inn bingo, the balls are different colours depending on the number just called.

    E.g. if the number is between 1 and 15, create a blue ball

    if the number is between 16 and 30, create a green ball.

    Then I want to do a whole lot of stuff with that ball. But I dont want to have to duplicate all that code for each ball colour, and I dont think you can pass balls (objects) in as parameters to a function.

    I actually solved the problem by making the balls different frames of a single sprite, but I'm interested if there is another way for cases where the sprite hack would not have worked?

    Many thanks for your thoughts.

  • Ha, so it will always be slightly longer than 1s, so it will accumulate a positive error over time.

    I assume I need to do something different, e.g. get the timestamp of now, then check every tick if the current time stamp is >= 1s different, then 2s differnt etc. This will not have the accumulative error.

    Looks like System.wallclocktime might be what i need? Im hoping this is similar to the unix timestamp in ms.

  • Is this event approximate, or fairly accurate? What I mean by that is that assuming the game is running at full speed (60fps?),

    1) would the timer be accurate to within miliseconds?

    2) would errors accumulate? Or if the system was busy of 2X seconds, would the event fire twice in quick succession, and "catchup" afterwards?

    3) If you say ran "every 1 second" say 1000 times (i.e. let the event fire 1000 times), would the elapsed time be 1000s +/- <1s?

    Thanks!

  • Wow, I had no idea you could legitimately use a blank sub event, I thought they were just temp placeholders for pasting in real sub event code.

    Great, that works!

  • if you define a new function, e.g.

    function On "test"

    then you want to add some local variables. However you try and add them, they always come out as global variables. Very frustrating.

    How do you add local variables to a function?

    I have seen how you can add them to a sub-event, but that's too late, I need to defined them before any of the sub events trigger, as they are set in the action of the function definition (i.e. used before they are defined!)

  • Thank you very much gentlemen.

    I was hoping to avoid the lerp route as my last project ended up 1000 events and it became an unmaintainable mess.

    I just tried out rex moveTo pugin, and it works exactly as I need. I am very surprised that C2 have not added moveTo as a built in - its very very useful and saves a lot of work.

    Pathfinding looks interesting, but for balls moving a few cm vertically in a bingo game, pathfinding is probably overkill (assuming it will treat all my UI elements as non solids?)

    Ill checkout liteTween also.

    All great suggestions - thanks again.