SOLVED loopindex not making a difference at first

Bugs will be moved here once resolved.

Post » Tue Apr 30, 2013 6:44 pm



SOLVED, check post #2

Link to .capx file (required!):
https://dl.dropboxusercontent.com/u/17328032/scirra/maybe_bugged_loop.capx

Steps to reproduce:
1. click on the blue button a couple of times
2.
3.

Observed result:
The 1st click spawns 5 sprites called "Score" overlapping each other.

Expected result:
Only the 2nd click (and further ones) spawn the sprites correctly (alongside each other). The expected result would be that the 1st click also spawned the instances alongside one another, and not overlaping each other.

You can get the expected result disabling Event #3 and enabling Event #4 on the capx.

Browsers affected:
Chrome: yes
Firefox: yes
Internet Explorer: yes

Operating system & service pack:
Windows 7 Ultimate & SP1

Construct 2 version:
Tried 124 and 127
    gamekill2013-04-30 18:59:16
B
10
S
2
G
3
Posts: 28
Reputation: 2,690

Post » Tue Apr 30, 2013 6:58 pm


Nevermind, solved it.
The problem was that since there was no sprite ("Score") present on the scene at the start of the "For" event, the specified multiplier in the Action (Score.Width) was zero. I was asking for a loopindex*Score.Width calculation, and the result was zero. Seems the "For" loop does not update this value at any iterations until it completes all of them (0 1 2 3 4) and exits.

So I solved it by splitting the action in two actions:
1 - create the sprite Score;
2 - move the sprite according to it's Score.Width.

Link to the solved capx:
https://dl.dropboxusercontent.com/u/17328032/scirra/fixed_bugged_loop.capx
B
10
S
2
G
3
Posts: 28
Reputation: 2,690


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 4 guests