A question about redrawing...

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Jesterscript
Prole
Posts: 4
Joined: Mon Nov 02, 2009 7:41 pm

A question about redrawing...

Post 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.
DustinEwan
Prole
Posts: 18
Joined: Wed Oct 21, 2009 7:20 pm

Re: A question about redrawing...

Post 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.
Jesterscript
Prole
Posts: 4
Joined: Mon Nov 02, 2009 7:41 pm

Re: A question about redrawing...

Post by Jesterscript »

Thank you, that's what I needed to know exactly.
Post Reply

Who is online

Users browsing this forum: Google [Bot], slime and 4 guests