weird glitch in my code

0 favourites
  • 6 posts
From the Asset Store
Tweakable and easy to use effects for your projects.
  • So I'm having a weird thing happening. in the following code block.

    a little explanation about what this does.

    MapCreate runs after I filled LevelArray with 50 random numbers.

    So as soon as it has created 50 map Icons it should be finished. after which I call location which sets the text to where the player is.

    now this event calls without a problem. but the event after. The for each MapIcon doesn't. but only doesn't the first time I call the function. if I call it after it works fine.

    any idea why this isn't working as intended?

  • New instances don't appear to forEach and similar lookups until the next tick.

    Try adding in a "wait 1" before calling the "location" function.

  • that fixed it, thanks Nepeo!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also your counter=50 condition doesn't seem to do much unless for some reason you are using it to catch the times you don't have 50 items in an array.

  • Good point by if you do need to check the count I'd advise that you use greater than or less than where possible instead of checking for equality in most situations. Helps if you make a bad assumption on the possible range of a value or you fall foul of floating point error.

  • good call. it was necessary in an older build but useless now. as it is always 50 now. thanks for the heads up

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