Clicking on sprite is lagging. Please help

0 favourites
  • 5 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • I want to move from one layout to another randomly.

    I first created a starting layout and added all the layout names as strings to an array object:

    I want to pick randomly the first three layouts and when there is no other left, move to Layout 4

    The problem is that clicking on the sprite to move to the next layout sometimes causes a lag. It's like I haven't clicked at all and sometimes it takes several clicks to move to the next layout.

    Please help me, thanks in advance!

  • Here's your problem: you're deleting an array entry, but still picking from a pool of 3. Therefore, sometimes when you click it tries to pick data from a slot you dropped already. You can visualise it like this:

    SLOT 0: [1]

    SLOT 1: [2]

    SLOT 2: [3]

    Then you go to Layout 1 and delete the array entry. Now the array looks like this:

    SLOT 0: [2]

    SLOT 1: [3]

    SLOT 2: [--]

    Now when C2 randomly chooses slot 2, it returns a null and the button doesn't work when you click it.

  • Thank you very much for your reply. Could someone provide me with an alternative solution?

    Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • goto Array.at( floor( random(0,Array.width) ) )

  • Seems to work! Thank you very much!

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