This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
extensions:shalphatexture [2012/03/13 07:09] – [Description] shilo | extensions:shalphatexture [2015/09/14 11:15] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | ====== SHAlphaTexture ====== | ||
+ | |||
+ | ---- dataentry extension ---- | ||
+ | type : extension | ||
+ | author_mail | ||
+ | description | ||
+ | lastupdate_dt : 2012-03-12 | ||
+ | compatible | ||
+ | depends | ||
+ | tags : texture, image, button, alpha, touch | ||
+ | homepage_url | ||
+ | download_url | ||
+ | ---- | ||
+ | |||
+ | ===== Description ===== | ||
+ | This extension enables the use of these 5 classes: | ||
+ | * SHAlphaButton | ||
+ | * SHAlphaImage | ||
+ | * SHAlphaTexture | ||
+ | * SHAlphaSubTexture (abstract) | ||
+ | * SHGLAlphaTexture (abstract) | ||
+ | |||
+ | The purpose of this extension is to allow Sparrow to be aware of when a touch inside a button or image contains a valid alpha value. | ||
+ | |||
+ | With the use of the property " | ||
+ | |||
+ | Note: These classes will store the alpha data and perform an extra check upon hitTest, so it should only be used when needing more accurate hit tests with textures containing transparent pixels. | ||
+ | |||
+ | Warning: The hit testing accuracy is not perfect and also depends on image quality. Use at own risk. | ||
+ | | ||
+ | ===== Sample ===== | ||
+ | [[http:// | ||
+ | * Project: [[http:// | ||
+ | * Recording: [[http:// | ||
+ | |||
+ | ===== Examples ===== | ||
+ | < | ||
+ | SHAlphaTexture *texture = [SHAlphaTexture textureWithContentsOfFile: | ||
+ | SHAlphaButton *button = [SHAlphaButton buttonWithUpState: | ||
+ | button.allowTouchOnAlpha = 0.5f; | ||
+ | [self addChild: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | SHAlphaImage *image = [SHAlphaImage imageWithContentsOfFile: | ||
+ | image.allowTouchOnAlpha = 1.0f; | ||
+ | [self addChild: | ||
+ | NSLog(@" | ||
+ | </ | ||
+ | ===== Source Code ===== | ||
+ | %gist(2027039)% |