First off:
@yojimbo2000’s mind-bogglingly great UI toolset for Codea is called Soda, and it is something everyone who uses Codea should see and get. Search ‘Soda’ and you’ll see it.
Now then:
Myself, a while ago, I posted a super-simple button system that basically worked like this:
- You write
button("hi there")
in yourdraw()
function - A button with the words “hi there” is drawn on screen
- By tapping a toggle in the overlay, you activate a draggable mode, and you can drag the button to any position you like, and the app remembers it even between launches
- You can set an action for the button manually in
setup()
Besides being dead easy, I really like this because it mimics the format of the standard Codea drawing commands like rect()
and ellipse()
. It feels Codea-like.
Since then I’ve been expanding on this idea, mainly by attempting to make a tool for creating two-choice adventure games (games like DoubleChoose, the app I just released with my daughters). My work so far: https://gist.github.com/DolenzSong/ef91fd371fd13fe1c00a
What’s I like is that, using this system, a complete sample game definition looks like this (and this exact “game” is in the project just linked to):
function sampleScreenA()
sprite("Cargo Bot:Game Area", WIDTH / 2, HEIGHT/2,WIDTH,HEIGHT)
textArea("sample game start screen")
choice("win sample game", sampleScreenB)
choice("lose sample game", sampleScreenC)
end
function sampleScreenB()
background(102, 94, 31, 255)
sprite("Cargo Bot:Star Filled", WIDTH / 2, HEIGHT/2,WIDTH,HEIGHT)
textArea("you won sample game")
choice("reset sample game", sampleScreenA)
end
function sampleScreenC()
background(75, 31, 31, 255)
sprite("Small World:Explosion", WIDTH / 2, HEIGHT/2,WIDTH,HEIGHT)
textArea("you lost sample game")
choice("reset sample game", sampleScreenA)
end
(textArea()
and choice()
are extensions of the button()
concept to different kids of UI elements, btw)
So:
@yojimbo2000, this is mainly a question for you:
- Soda is so beautiful that I just can’t bear the thought of trying to re-implement any of its of features–rounded rectangles, for instance–when you’ve basically done it perfectly already.
- The Soda system seems vastly incompatible with this system I’m developing. It’s object-based, not function-based, just for starters.
- Is there any way I can keep the simplicity of my system but have the beauty of your buttons? It must be possible somehow, right? Can you give me any pointers on how to do it?