We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
tint() (Read 954 times)
tint()
Dec 28th, 2009, 8:56pm
 
Just a quick question on image transparency..
i was wondering..I'm trying to make it so that when my character 'collects' an item the image of the item disappears.. is there a way that I can do this, like using 'null' for an image parameter, or should I change it so it's like:

tint(255, 0);
image(item, x, y);

?
Re: tint()
Reply #1 - Dec 29th, 2009, 12:44am
 
Yes, don't draw the image ...
Re: tint()
Reply #2 - Dec 29th, 2009, 1:04am
 
Exactly - if you're drawing a fresh background each frame just don't draw the image once it's collected (if your items are class based you could just build a condition into the item's display method).  Your solution is rather inefficient since you're still requesting it to be drawn, albeit with alpha = 0...
Re: tint()
Reply #3 - Dec 29th, 2009, 9:47am
 
I did make it so that my items are class-based, but I was just unsure about how to make a condition so that it won't draw that one class after it has been collected..it seems like a simple enough problem, I'm just overlooking something =x. Would I say like:

if (collect == true){
    image(null, x, y);
}

or I believe null isn't a valid parameter for 'image.' =/
I just don't know how to actually make it so that the item disappears once collected.
Re: tint()
Reply #4 - Dec 29th, 2009, 9:52am
 
Put the condition around the code where you draw it:

if(!collect){
 image(myImg,x,y);
}

i.e. if the item hasn't been collected draw it, otherwise do nothing...
Re: tint()
Reply #5 - Dec 29th, 2009, 10:08am
 
That makes sense xD;
heh, thanks, that works.
Page Index Toggle Pages: 1