R193 Picked Count with Timer Event Bug

Bugs will be moved here once resolved.

Post » Wed Jan 07, 2015 6:14 pm

Problem Description
I've attached Timer behavior to a "Text" Family object and assigned number of ball to to each team (Team1=2 ,Team2= 3,Team3=6)
Each timer event, the text object will be updated with total of picked count of their respective ball. However it displays the picked count incorrectly ? All 3 team display 4.

Attach a Capx

Description of Capx
It just consist text family with timer behavior which will update their text with Ball.PickedCount expression. Each ball already have instance variable "team1", team2" and "team3" and has been arranged bellow their respective team.
All team text object also has instance variable team with value of "team1","team2" and "team3" .

Steps to Reproduce Bug
  • Run the capx.
  • All team will display value of 4 ?

Observed Result
All team display total of picked count 4 which is kinda weird since I don't know how it comes up with that number

Expected Result
Each team display the correct value. E.g Team1=2 , Team2=3, Team3=6

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (YES)

Operating System and Service Pack
Windows 8.1 Pro

Construct 2 Version ID
Posts: 391
Reputation: 12,958

Post » Mon Jan 12, 2015 3:59 pm

Closing as not a bug. A quirk of the Timer behavior is 'On timer' can run with multiple instances picked (all the instances that fire the timer at the same time). So 'On timer onUpdateScore' fires with the entire 'Teams' family picked, because all their timers fire at the same time.

Then "Ball team = Teams.team" becomes ambiguous since you are comparing 11 balls against the 3 instances in the Teams family. I think the C2 engine attempts pairing when you do this, and will try to match the first 3 balls with the first 3 Teams, then the next 3 balls with the first 3 Teams, and so on, which I think is how it comes up with the somewhat non-intuitive number 4.

The solution is just to add "For each Teams" under the "On timer" event. Then it handles each instance separately and it works correctly.
Scirra Founder
Posts: 24,895
Reputation: 198,598

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 4 guests