I have long been ashamed of the clunky look of the buttons I made for my daughters’ app (DoubleChoose, available on the App Store!).
I have also long been trying to write my own button API, and in the process somehow decided to rewrite the whole darn app from scratch.
Mercifully, some sanity has descended.
There’s no need to rewrite the app. The app works. And @yojimbo2000 has already written the very best Codea button API I have ever seen. In fact, it’s the very best third-party Codea API that I’ve seen, period. It’s called SODA (you can find it by searching “soda” on the forums).
So thanks @yojimbo2000, for making this incredible thing.
That said, I’m having a really pretty terrible bug: when I run SODA as a dependency, the Codea controls do not appear on screen, nor are they invisible but functional. To stop a running project, I have to leave the app, terminate it, and restart it. Needless to say, this is not workable long-term.
Here is my “main” class, which is just copied directly from the template:
-- Main
saveProjectInfo( "Description", "Two-choice Adventure Games by Rosie and Charlotte." )
-- Soda
displayMode(OVERLAY)
displayMode(FULLSCREEN)
-- Use this as a template for your projects that have Soda as a dependency.
function setup()
saveProjectInfo("Description", "Soda v"..Soda.version)
profiler.init()
Soda.setup()
parameter.watch("Soda.focus.title")
overview{}
-- demo1() --do your setting up here
end
function draw()
--do your updating here
pushMatrix()
Soda.camera()
drawing()
popMatrix()
profiler.draw()
end
function drawing(breakPoint)
--in order for gaussian blur to work, do all your drawing here
background(40, 40, 50)
sprite("Cargo Bot:Game Area", WIDTH*0.5, HEIGHT*0.5, WIDTH, HEIGHT)
Soda.draw(breakPoint)
end
--user inputs:
function touched(touch)
if Soda.touched(touch) then return end
--your touch code goes here
end
function keyboard(key)
Soda.keyboard(key)
end
function orientationChanged(ori)
Soda.orientationChanged(ori)
end
--measure performance:
profiler={}
function profiler.init(quiet)
profiler.del=0
profiler.c=0
profiler.fps=0
profiler.mem=0
if not quiet then
parameter.watch("profiler.fps")
parameter.watch("profiler.mem")
end
end
function profiler.draw()
profiler.del = profiler.del + DeltaTime
profiler.c = profiler.c + 1
if profiler.c==10 then
profiler.fps=profiler.c/profiler.del
profiler.del=0
profiler.c=0
profiler.mem=collectgarbage("count", 2)
end
end
Right now, I’ve replaced the DoubleChoose app’s own “main” tab with this, just to get started with it.
I have no idea what’s causing this problem, but having come to my senses about not reinventing the wheel, I hope I can get the awesome already-invented wheel to roll.