PDA

View Full Version : currently porting from Cocoa to Quartz 2d...




dave.h
May 20, 2005, 02:33 PM
I was previously using NSImage References for all my sprites, which made it relatively easy to draw semi-transparent images, using

[myImage drawInRect:dest fromrect:src operation:op fraction:(1.0 - transparency)]

However, I'm currently in the process of porting my game to Quartz, and I'm using the operation

CGContextDrawImage( myContext,
myRectToDrawIn,
myImgSource);

I have a feeling drawing semi-transparently has something to do with CGSetRGBFillColor, but I'm not completely sure. Transparency is very important in my graphics engine, so... I'm kind of crippled in development before I figure this out.



dave.h
May 23, 2005, 02:28 PM
i figured out the answer

CGContextSetAlpha(0.25)

draw something

CGContextSetAlpha(0.5)

draw again

CGContextSetAlpha(1)

draw fully visible.