Page 1 of 1

A question about redrawing...

Posted: Mon Nov 02, 2009 8:21 pm
by Jesterscript
Hi all, I'm using LÖVE (simply amazing fw by the way, I LÖVE it :) ) in some kind of object oriented approach, implemented in Lua by use of metatables as described in lua-users.org tutorials. I have some independent objects on screen, every object has (as it's class dictates) a draw() method and an update() method. The question is, Do I have to control when to redraw things by myself? or the 'draw' callback does that for me. I've read the documentation about draw callback and didn't find anything like:

Code: Select all

if(object.needsRedraw())
{
    object.redraw() -- where redraw() method should turn off a redraw flag for object until next redrawing is needed.
}
..thats why I'm asking about redrawing management. I hope I have been clear and thanks in advance.

Re: A question about redrawing...

Posted: Mon Nov 02, 2009 8:40 pm
by DustinEwan
I'm not sure if I fully understand your question, nor do I know if this is proper or not, but I think you have two options:
  • Just have the needsRedraw return a bool on it's ready-to-redraw state and do the actual drawing within the draw callback function.
  • Have the full redraw logic be self-contained with the object and simply iterate through your objects in the draw callback and let the objects worry about whether or not they need to redraw or not, and if so, just let them do it themselves.

Does that make sense? From what I understand, yes, you're free to dictate the drawing of objects as you wish. The draw callback is there just to give you a nice location for organizing all your draw logic. I suppose you could also do all your drawing in the update callback if you really wanted.

Re: A question about redrawing...

Posted: Mon Nov 02, 2009 8:59 pm
by Jesterscript
Thank you, that's what I needed to know exactly.