I am coming froma Canvas Modelled Language, like HTML5 and just trying to get to grips with LUA, I know the principles of loading a canvase, writing to the hidden canvas and then once finished rendering placing it scalled into view, but a little confused by the Object way done in Gideros, Can somone simply describe what the modal is for handling the display of Graphics and Sprites?
REAL programmers type copy con filename.exe
---------------------------------------
Comments
I'm new to Gideros myself, but I'll have a crack at answering your question and someone will correct me if I'm barking up the wrong tree.
"Object" is a term from Object Oriented Programming (OOP), and to start with it will be helpful to get a grounding in that. Lua isn't exactly an OOP language, but it kind of emulates one.
Gideros adds a bunch of functions which are modelled on Actionscript 3, so that's also useful to know. I'm currently juggling "Programming in Lua" (Roberto Ierusalimschy), and "Learning Actionscript 3" (Rich Shupe) along with the Gideros documentation. One of the forum members who posts as OZApps has also written an introductory book on Lua which includes a section on Gideros - see here:
http://www.apress.com/9781430246626
To answer your question, you have the idea of a hierarchy of containers descending from the "stage" which kind of represents the display. The stage holds sub-containers called "sprites" which in turn can hold bitmaps and shapes drawn within Gideros.
A shape or bitmap can be added as the "child" of a sprite by using its "addChild" method. Likewise, the sprite can be added to the stage, or display, by using the stage's addChild method. The graphics within the sprite can then be concealed or revealed by removing them as the sprite's children and adding them again. If you study the built-in examples like "Bird Animation" (bitmaps) and "Drag Me" (shapes) you'll hopefully start to get the idea...
Think of it a bit like the DOM in HTML5, Canvas on the other hand is what's know as a "direct mode" approach and you have to specify what you want to draw each frame by issuing the draw calls in the right order.
Each approach has it's pro's and con's, Codea on the iPad for instance uses a "direct" approach and can be more flexible - especially for things like particle systems and having to replicate lot's of sprites, but you generally have to write more code and keeping a clean separation between logic and rendering is harder.
Hope this helps.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
http://www.lua.org/pil/16.html
Likes: phongtt
---------------------------------------
The best part is that you do not have to call the draw method explicitly (unless it is a shape object) and they are redrawn as you change the display attributes of the objects.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
What I am looking at now is how to control the event, I am used to firing a call back where an animation may occur via a count down, so if the count goes down to 0(Zero) the routine doesn't call back, and it stops, in effect only animating when something needs to animate, I don't see how the animation or timed events are controlled. I am looking at the bird sample, and I see a child adding the sequences. but I don't see how the animation is cycled? I am still reading through the docs at the moment, so not started any coding, it may become more clear to me as I proceed.
Regards
---------------------------------------
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps