Timeline for Pset3 (breakout) -- problems initiating score label
Current License: CC BY-SA 3.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 13, 2015 at 0:13 | comment | added | i_am_david | @ChrisG is this a good question to add bounty to? cs50.stackexchange.com/questions/12220/… | |
Aug 12, 2015 at 17:52 | vote | accept | mathmagician | ||
Aug 12, 2015 at 16:15 | comment | added | ChrisG | If this answers your question please accept it by clicking the gray check-mark to the left, so that it becomes green. You can also vote it up by pressing the up arrow above the check-mark. | |
Aug 12, 2015 at 16:14 | comment | added | mathmagician | Oh dear, you're right! Everything works now, thanks for spotting that! | |
Aug 12, 2015 at 15:47 | comment | added | ChrisG |
I don't see anywhere in your code a call of updateScoreboard .
|
|
Aug 12, 2015 at 15:45 | comment | added | mathmagician | Added all the code to the question :) | |
Aug 12, 2015 at 15:20 | comment | added | ChrisG | Could you also include this piece of code in your question? | |
Aug 12, 2015 at 15:19 | comment | added | mathmagician | Also done in that order. | |
Aug 12, 2015 at 15:13 | comment | added | ChrisG | No. Here you posted the functions. I'm talking about where you call them. | |
Aug 12, 2015 at 15:09 | comment | added | mathmagician | It's done in the same order that I posted it here, so it is first created, and only then updated. | |
Aug 12, 2015 at 15:07 | comment | added | ChrisG |
Look at which line is the label created (i.e. initScoreboard called) and at which it's updated (i.e. updateScoreboard called). I can't be sure without looking at your code but if I had to guess it would be that you first update and then initialize the scoreboard?
|
|
Aug 12, 2015 at 15:03 | comment | added | mathmagician | But isn't points automatically set to 0? I mean, this line: sprintf(s," %i", points); refers to variable 'points' which has been initialised to 0 earlier on in the program. Isn't the problem then with how the score label is linked to the score-update function, rather than with it not being initialized to 0? | |
Aug 12, 2015 at 13:36 | comment | added | ChrisG | Since you start with 0 points you should initialize it displaying 0. The updateScoreboard is to increment the points shown when you gain them. | |
Aug 12, 2015 at 13:34 | comment | added | mathmagician | Yup, but the point is that it is meant to display the label with the score from updateScoreboard. I assumed that this line: setLabel(label, s) took care of adding the score into the initiated label, especially since it's pre-written by the course-staff, but apparently not, and I don't know how to fix it. | |
Aug 12, 2015 at 13:31 | comment | added | ChrisG | It's because the <space> is an invisible character. So the label is there but it doesn't show. | |
Aug 12, 2015 at 13:24 | comment | added | ChrisG |
If you change newGLabel(" ") to newGLabel("0") does it show?
|
|
Aug 12, 2015 at 13:22 | comment | added | mathmagician | Thanks, did this, but it's still not working. However, if you change GLabel label = newGLabel(" "); to GLabel label = newGLabel(" WHATEVER") the thing works fine :/ | |
Aug 12, 2015 at 13:16 | history | answered | ChrisG | CC BY-SA 3.0 |