开发者

Get the alpha value at the touched point on a sprite in Cocos2D

I am doing an application where I need to get the alpha valu开发者_Python百科e at the touched position on a sprite. Thanks in Advance


I use this code to retrieve the alpha value:

GLubyte pColor[4];
CGPoint newpoint = (...your screen point in GL coordinates);
glReadPixels(newpoint.x,newpoint.y,1,1,GL_RGBA,GL_UNSIGNED_BYTE,&pColor[3]);

pColor[3] then contains your alpha value.

You probably will have to combine this with code to check whether your position is inside the sprite's bounding box. Make sure you get the right coordinates.


Probably it what you need sprite.alpha.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜