R193 Picked Count with Timer Event Bug

0 favourites
  • 2 posts
From the Asset Store
An educational game for counting pictures. An easy to use template for developers to build larger games
  • 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

    https://dl.dropboxusercontent.com/u/65841566/R193%20Picked%20Count%20expression%20in%20Timer%20Event%20Bug.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

    R193

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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