It looks like you're new here. If you want to get involved, click one of these buttons!
I have been looking through the examples in Codea - specifically the 'Spritely' example because it uses an info button to display instructions - however, I am having difficulty reading through the various tabs trying to decipher and pick out the relevant code to help me do this. I must not be fully understanding the touch class with regard to this? I have tried examples and I get output that tells me the button has been activated.. (using a sprite as a button - thanks ChrisF!).. also that a single or double tap has occurred and swiping too but I just can't work out how to make the action bring up a window / new screen. I am new to coding in general so sorry in advance if this is a dumb question but is there anyone that could explain this in simple terms to me and help me out please?
Comments
Here is something I had from long ago that might give you an idea. There are a lot of different ways to do what you are asking.
This is great! It makes it really clear for me and I now totally get it. Thanks so much .. :-D
this is really what i'm looking for but I feel I dont understand the everything here. Please bare with the noob questions.
Why doesn't it work calling menu() from draw()?
When does the easy, medium and hard functions get called?
trying to learn how to set up buttons but feel i dont really get it.
If you call menu() from draw, that's all you'll be calling 60 times per second. The call to func() allows you to change what function is getting called. Func() starts out as being Menu, so that's what gets executed. While you're in menu, you have the option to call easy, normal, or hard depending on what button you touch. When you make a selection, Func is assigned a function ( easy, normal, or hard ) and that's what gets called in draw. You just keep moving between screens based on what you select.
thx dave for super quick response. I think what was confusing to me was that func could change which function it was in that way.
Ok, so here's another noob follow up question. I used your code and trying to apply it to how think / would like to design the code. Problem is: I dont understand why it doesnt write "click" when state is set to 1 by the touch event. I know the code gets into the if but why doesnt it print "click"?
In FULLSCREEN mode you cant see the output panel where things are printed. Comment this line to see it.
In the section "if state == 1 then" the line of code "text("click" ' w, h)" is wrong. The ' should be a , . It should be text("click", w,h) . Also, when to tap explore, you set state to 1 and print the value 1 every time draw is called, 60 times a second. Each time you tap explore, the word click prints, but is pushed off the top of the print window by all the 1's printing.
Try changing the if statement to this. The problem is you're mixing text and print. If you want print to work, then set state to 0. If you want text to show, then you don't set state to 0 but print will show 60 times a second which is what you don't want to do.
Oh, fantastic! I just had the print there for debug reasons. Maybe i should have said so.
Thinking of what im trying to achieve i think your example will be perfect. Will do some more coding and see how it goes.
Once again, super big thanks!