Clicking on sprite is lagging. Please help

Just started using Construct 2? Post your questions here

Post » Thu Aug 10, 2017 8:14 pm

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:

Image

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

Image

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!
B
3
Posts: 3
Reputation: 181

Post » Thu Aug 10, 2017 10:48 pm

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.
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 209
Reputation: 3,476

Post » Fri Aug 11, 2017 6:54 am

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

Thanks in advance!
B
3
Posts: 3
Reputation: 181

Post » Fri Aug 11, 2017 9:34 am

goto Array.at( floor( random(0,Array.width) ) )
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Aug 11, 2017 12:22 pm

Seems to work! Thank you very much!
B
3
Posts: 3
Reputation: 181


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest