Dear Sarah,
First of all kudos to the whole effort of training the innocent little
minds. This is amazing.
Few points about why the program wouldn't work (following which is a
revised working version):
1. couldn't find 'url' in the shoes manual, probably what you're
looking for is 'link'
2. The index method has to be defined before it is called, ruby
doesn't know where to look if you call it before defining it.
3. the index method would create new instance variables each time you
call it after making an answer, so your old click event handlers will
get blown away (technically because your instance variables are
re-referenced to new objects each time you call index). Its best to
define the click event handers again, within index itself.
Working version:
Shoes.app {
# first define index
def index
clear
para "Which is correct?"
stack {
@correct = button "A bed of clams"
@wrong1 =button "A coalition of cheetahs"
@wrong2 =button "A gulp of swallows"
# button event handlers
@correct.click {
clear
para "Correct"
image
"http://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Balloons-aj.svg/550px-Balloons-aj.svg.png"
button "Go Back" do
self.clear { index } # call index again
end
}
@wrong1.click {
clear
para "Wrong!"
image
"http://icanhascheezburger.files.wordpress.com/2007/05/cheez_doing_it_wrong.jpg"
button "Go Back" do
self.clear { index } # call index again
end
}
@wrong2.click {
clear
para "Wrong, your consolation prize is..."
image "http://farm2.static.flickr.com/1166/1230713908_083d7f6c53_o.jpg",
:width => 500
button "Go Back" do
self.clear { index } # call index again
end
}
}
end
# then call index
index
}
Best wishes,
Joel
On Fri, May 29, 2009 at 6:54 AM, Sarah Allen <[email protected]> wrote:
>
> This is a question from two of my fifth grade students. I thought this was
> how to sign up for the list, but either I got it wrong, or there's a delay.
> Hope there is an experienced Shoes developer on the list who can provide some
> insight. We're preparing for a class tomorrow where I will attempt to teach
> the kids how to develop an interactive game
> (Trying to apply lesson from p. 31 of You Don't Know Shoes)
> Thanks!
> Sarah
> ----- Forwarded Message -----
> From: [email protected]
> To: [email protected]
> Cc: [email protected]
> Sent: Thursday, May 28, 2009 6:13:26 PM GMT -08:00 US/Canada Pacific
> Subject: Help with our app?
>
> We don't understand why this app won't work it only shows a blank screen.
>
> Shoes.app {
> url '/', :index
>
> index
>
> def index
> clear
> para "Which is correct?"
> stack {
> @correct = button "A bed of clams"
> @wrong1 =button "A coalition of cheetahs"
> @wrong2 =button "A gulp of swallows"
> }
> end
> @correct.click {
> clear
> para "Correct"
> image
> "http://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Balloons-aj.svg/550px-Balloons-aj.svg.png"
> button "Go Back", :click => "/"
> }
> @wrong1.click {
> clear
> para "Wrong!"
> image
> "http://icanhascheezburger.files.wordpress.com/2007/05/cheez_doing_it_wrong.jpg"
> }
> @wrong2.click {
> clear
> para "Wrong, your consolation prize is..."
> image "http://farm2.static.flickr.com/1166/1230713908_083d7f6c53_o.jpg",
> :width => 500
> }
> }
>
> Thank you,
> Sincerely New Shoes Developers