[SOLVED]Troubles with dynamically allocated object

0 favourites
  • 2 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hi there, i'll briefly introduce the context of my problem.

    I'm using r119 on Chrome. r119 because when i updated to a newer release, some things that worked before didn't seemed to work, so i'll stay on r119.

    I'm working on a casino game, a roulette. I receive all the information that i need (money, state of the buttons, position and value of coins), from a server running on other computer.

    These days i've been struggling with construct trying to create the coins on runtime. I receive the command to make a coin and parse it's slot ID, and it's value without problem, but when i try to create a Coin with the System.Create Action, i get a headache trying to save some reference to that coin.

    Note: the old versions of the program are deleted, so i only'll remake them for the pictures

    First, i've tried to save the UID on a global variable and retrieve it immediately after creating the coin. pics:

    <img src="http://img593.imageshack.us/img593/8900/getuid.png" border="0" /><img src="http://img14.imageshack.us/img14/6949/greencreate1.png" border="0" /><img src="http://img94.imageshack.us/img94/6035/coinsfly.png" border="0" />

    ..and later reference it by its UID

    <img src="http://img32.imageshack.us/img32/5038/coinreferenceuid.png" border="0" />

    That worked really bad! Never put a coin.. after some debugging with the console, i found that construct only is capable of picking by uid the object on the next tick after its creation. So, i added a wait action, and then, it worked somewhat nice, only had troubles if i clicked really fast.

    However, the reference says that a wait action in a for loop only will pause the currently running thread. So, the for loop will begin executing again for the next iteration if you put there a wait action. I load the coins in a for loop because i need to load several coins at once in many cases, for instance, if the game losses connection, or the players computer unluckly reboots, when the connection restablishes, the game must continue where it was left. In that context, the multithreaded environment without any system-made semaphores, really scared me. Then, i looked for another approach. Added to the Conis' CoinID variable -1 as initial value, and picked it by that value. Pic:

    <img src="http://img543.imageshack.us/img543/7382/coinreferencecoinid.png" border="0" />

    Worked fine, until i began sending more than one coin at once. Then it failed terribly, only put the first coin. Ignored the rest at the picking by instance variable. I put a foreach to dump all of the coins to the console, and terrified saw that always were only one coin. Furthermore, i've logged this to the chrome console immediately after the pick all Coins condition

    Coins.PickedCount &" coins picked vs "&Coins.Count&"actual coins"

    and saw things like "2 coins picked vs 4 actual coins". This is where i'm stuck now, kind of desperate because of this weird behavior.

    Anyway, thank you in advance for taking the time of reading all if this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nevermind, find it out myself.. here's the explanation of the problem if someone is interested


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