i need a window class for various purposes. I’ve made several attemps in the past but my code was not easy to maintain so i didnt like it. I have the project to try again, but using cargobot code and classes (screen, panel and button) for the bases. Here is the ‘spec’ i have in mind.
Any advice, recommendation (or help) is welcome.
This might not be a great suggestion this time round @Jmv38 but inheritance is good for this sort of project. I’m sure you looked at my toolbar ui, it’s pretty basic and doesn’t use inheritance but I have to rewrite functions which is something you can miss with inheritance if you use it correctly. You don’t need to use inheritance all round though. My code is littered with variables because of this. Have a look at how apple uses objects in Xcode, it is ideal to say the least. Objects (classes) for every element no matter how different, even for different different types of text boxes/labels. That’s all I can say for now I’m sure someone else will go in to more detail for you.
@luatee thanks for the suggestions.
Actually my arrows didnt really meant to suggest inheritance (some, but not all of them).
Studying cargobot it have understood how TLL implement it with classes, it is ok for me.
I have made some progress thanks to cargoBot and your help.
The first step was to make a button library that fits into a screen concept.
Here it is https://gist.github.com/anonymous/30b839d752d2922d0096
The buttons have a rectangle (rounded), an image and a text, all optionnal.
They react to many usual touch events.
The live editor function are limited to positionning the buttons, which is the main thing you cant do easily from the code.
I’ve included a series of screens that make a quick tuto.
All feedback welcome.
Here is a screenshot on one of the tuto screens:
if you want a quick start, here is a minimal ‘hello world’ program. Make a dependecy to xfc 3.0 (prog above) and it will work
-- Hello world program
-- create screen
screen1 = Screen()
backgroundButton( screen1, color(30, 31, 102, 255))
Editor.addEditorButtonToScreen( screen1 )
-- create button
local b = Button("hello")
-- display screen
Good works ! ( And thanks for credits )
@Jmv38 Thank you! I think this solve my problems (enable/disable)
@hyrovitaltprotago and @erickyamato thanks.
Does the ‘triple tap to show the editor’ feels right to you?
@erickyamato there are many meanings behind enable/disable. The solution depends also on how things are implemented (architecture). This lib provides many different input points to disable a button: you can
- make it not touchable b:setTouchable(false),
- or set the specific touch action inactive: b.onTap = b.doNothing
Yes, good idea. Just a little question, what do you think about animation compatibility with Tweens ? Move, Resize, change style and others things feels easy or not ?
@hyrovitaltprotago you mean animation in general or the transition animation between screens in this lib?
Animation in general for all objects.
in this lib i use tween to offset the screens in and out. I have use them in general with tanslate, scale and rotate, when opening or closing an object. I have not used them for live game elements animation. I think TLL is cooking up another lib (juice) that is more suited for animating game objects.
The window lib is ready. I’d love to post it right now, but i’m going to be out of wifi for 1 week, so i wont be online to answer the questions… So i’ll post it next week.
@Jmv38 Looking forward to it, I like the ideas you’ve put together on how to use buttons differently rather than just press and release.
@Jmv38, out of wifi!? X_X
Can’t wait to see what you’ve cooked up.
Here is the new version xfc-3.1: https://gist.github.com/anonymous/3017b8ab57a5649ad34f
Here is a screenshot:
And there is quite some more in the code, but to discover it you’ll have to load it and run it…
@luatee thanks! I kind of like the onEnter() and onLeave() because the ones are usually difficult to get from just Began/Moving/Ended states but are important to make a continuous fire button. OnFinished is new in this version, i’ve added it because it was needed for a D-pad.
@JakAttak thanks, i hope you’ll like the new stuff.
Any feedback or question?
@Jmv38, sorry I have not downloaded the code yet, I am having iOS 8 beta troubles for importing into Codea
However, based on the screenshot, it looks great Keep it up!