Array Manipulation / 'for Loop' Problem

Discussion in 'Buildbox 3.0' started by Scriv, Dec 2, 2018.

  1. Scriv

    Scriv Boxer

    Joined:
    Oct 28, 2018
    Messages:
    50
    Likes Received:
    22
    so I can find a list of coins onscreen by using the line:-
    let _coins = this.scene().find('coin');
    which returns a list of [object.entity]'s which is GREAT BUT if i pop that array into a 'for loop' to signal each coin onscreen (in this case to activate a 'remove' node) then the subsequent loop takes place over one frame....which doesn't look grerat and crashes the player if the signal triggers a spawn or any sort of animation. (say the coin disappears with a flash)

    im guessing this is a simple system overload and i need to delay the signals by a few frames to allow the game to perform the tasks and not flip out.

    Question.
    1)How can I separate/delay the actions of a 'for loop' over multiple frames?
    2) can anyone tell me the code for accessing individual objects within an array so that i could manually build a loop within the update function?

    thanks in advance. again this has had me stumped for a week or so now....im out of ideas.
     
  2. Scriv

    Scriv Boxer

    Joined:
    Oct 28, 2018
    Messages:
    50
    Likes Received:
    22
    Actually, quite by chance i found the answer just hours after writing this post. I can manually reference an array's instance by putting [] after the variable. i linked that [instance number] to an incaramenting vaiable and i was away. pretty coins disappearing. Im learning javascript as i go along so this is a pretty big deal for me. Do i know how to party or WHAT?!
     

Share This Page