Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Fri Feb 28, 2020 8:44 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: color and colorfilter
PostPosted: Sun Oct 19, 2014 8:01 pm 
Offline

Joined: Sat Oct 12, 2013 4:48 pm
Posts: 44
If i specifie the color as FILTER which is (0,0,0,0) then the variable colorFilter is used
if not then "color" is used which is not a declared variable and you can set this by default in the prototype function. ok so far i get what is happenning but what is the purpose of this in you design?? can you give me an example of when this is usefull.

In the book it says on page 127 paragraph 5.5.1
"The coloFilter property is a way to specify a color that is always applied when drawing the image"
I really do not understand what you mean in that sentence can you explain more in depth please??

can I not just get rid of color and do this in the drawframe function
sprite->Draw(texture, rect, null, null, colorfilter).


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 24, 2014 12:04 pm 
Offline
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 554
The colorFilter property in the Image class allows us to assign a unique color filter to each image object. This would be useful for example if we had an array of Image objects all drawn using the same texture image but where we want each image to have its own unique color. We could draw all of the images objects in a simple loop like this:

    for(int i=0; i<OBJECT_COUNT; i++)
    image.draw(graphicsNS::FILTER);

Each object would be drawn using its colorFilter property.

_________________
Professor Kelly


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group