Changeset View
Changeset View
Standalone View
Standalone View
src/activities/number_sequence/number_sequence.js
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
46 | 46 | | |||
47 | function stop() { | 47 | function stop() { | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | function initLevel() { | 50 | function initLevel() { | ||
51 | items.bar.level = currentLevel + 1 | 51 | items.bar.level = currentLevel + 1 | ||
52 | items.pointIndexToClick = 0 | 52 | items.pointIndexToClick = 0 | ||
53 | loadCoordinates() | 53 | loadCoordinates() | ||
54 | eraseSegments() | ||||
54 | loadBackgroundImage() | 55 | loadBackgroundImage() | ||
55 | if(mode == "drawletters" || mode == "drawnumbers") { | 56 | if(mode == "drawletters" || mode == "drawnumbers") { | ||
56 | //function to play letter sound at start | 57 | //function to play letter sound at start | ||
57 | playLetterSound(dataset[currentLevel].sound) | 58 | playLetterSound(dataset[currentLevel].sound) | ||
58 | } | 59 | } | ||
59 | } | 60 | } | ||
60 | 61 | | |||
61 | function nextLevel() { | 62 | function nextLevel() { | ||
Show All 13 Lines | |||||
75 | //function to play the sound of character at start & end | 76 | //function to play the sound of character at start & end | ||
76 | function playLetterSound(sound) { | 77 | function playLetterSound(sound) { | ||
77 | // first we clear the queue in case other voices are there, then we append the new number | 78 | // first we clear the queue in case other voices are there, then we append the new number | ||
78 | // if we play directly, we don't have the bonus sound (or it is truncated) | 79 | // if we play directly, we don't have the bonus sound (or it is truncated) | ||
79 | items.audioVoices.clearQueue() | 80 | items.audioVoices.clearQueue() | ||
80 | items.audioVoices.append(sound) | 81 | items.audioVoices.append(sound) | ||
81 | } | 82 | } | ||
82 | 83 | | |||
84 | function eraseSegments(){ | ||||
85 | for(var i = 0; i < items.segmentsRepeater.count; i++) | ||||
jjazeix: In which case are we not in one of these cases? | |||||
shubhammishra: for none :( | |||||
86 | items.segmentsRepeater.itemAt(i).opacity = 0 | ||||
87 | } | ||||
88 | | ||||
83 | 89 | | |||
84 | function drawSegment(pointIndex) { | 90 | function drawSegment(pointIndex) { | ||
85 | if (pointIndex == items.pointIndexToClick) { | 91 | if (pointIndex == items.pointIndexToClick) { | ||
86 | var currentPoint = items.pointImageRepeater.itemAt(pointIndex) | 92 | var currentPoint = items.pointImageRepeater.itemAt(pointIndex) | ||
87 | // if we need to draw only a point instead of a line | 93 | // if we need to draw only a point instead of a line | ||
88 | if(mode == "drawletters" || mode == "drawnumbers") { | 94 | if(mode == "drawletters" || mode == "drawnumbers") { | ||
89 | currentPoint.highlight = false | 95 | currentPoint.highlight = false | ||
90 | if(pointIndex == 0 || (pointPositions2 && pointPositions2[pointIndex] != pointPositions2[pointIndex-1])) { | 96 | if(pointIndex == 0 || (pointPositions2 && pointPositions2[pointIndex] != pointPositions2[pointIndex-1])) { | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
139 | } | 145 | } | ||
140 | 146 | | |||
141 | function loadBackgroundImage() { | 147 | function loadBackgroundImage() { | ||
142 | items.imageBack.source = url + dataset[currentLevel].imageName1 | 148 | items.imageBack.source = url + dataset[currentLevel].imageName1 | ||
143 | items.imageBack2.source = url + dataset[currentLevel].imageName1 | 149 | items.imageBack2.source = url + dataset[currentLevel].imageName1 | ||
144 | } | 150 | } | ||
145 | 151 | | |||
146 | function won() { | 152 | function won() { | ||
147 | items.bonus.good("flower") | 153 | items.bonus.good("flower") | ||
instead of changing it twice in initLevel and in won, would it be better to always connect the signal in Bonus to an internal slot and in this slot, check if mode == 1. If yes, we call Activity.nextLevel? jjazeix: instead of changing it twice in initLevel and in won, would it be better to always connect the… | |||||
148 | } | 154 | } |
In which case are we not in one of these cases?