This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCSprite *texture = [CCSprite spriteWithFile:@"texture.png"]; | |
texture.blendFunc = (ccBlendFunc) { GL_ZERO, GL_ONE_MINUS_SRC_ALPHA }; | |
[scene addChild: texture]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:@"mysprite.png"]; | |
sprite.blendFunc = (ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; | |
// or | |
[sprite setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds] | |
pixelFormat:kEAGLColorFormatRGBA8 // not kEAGLColorFormatRGB565 ! | |
depthFormat:0 //GL_DEPTH_COMPONENT24_OES | |
preserveBackbuffer:NO | |
sharegroup:nil | |
multiSampling:NO | |
numberOfSamples:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCMenuItemImage *menuItem = [CCMenuItemImage ...]; | |
// Make touch area centered and 4 times smaller than bounding box | |
menuItem.touchArea = CGRectMake( | |
menuItem.contentSize.width/4, | |
menuItem.contentSize.height/4, | |
menuItem.contentSize.width/2, | |
menuItem.contentSize.height/2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@synthesize touchArea=_touchArea; | |
// ... | |
// Initialize the touchArea to the outside box | |
-(void) setContentSize:(CGSize)contentSize { | |
[super setContentSize:contentSize]; | |
_touchArea = CGRectMake(0, 0, contentSize_.width, contentSize_.height); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** the touch area (relative to the current position) */ | |
@property (nonatomic,assign) CGRect touchArea; | |
// and remove the 'rect' method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(CCMenuItem *) itemForTouch: (UITouch *) touch | |
{ | |
CGPoint touchLocation = [touch locationInView: [touch view]]; | |
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; | |
CCMenuItem* item; | |
CCARRAY_FOREACH(children_, item){ | |
// ignore invisible and disabled items: issue #779, #866 | |
if ( [item visible] && [item isEnabled] ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(CCMenuItem *) itemForTouch: (UITouch *) touch | |
{ | |
CGPoint touchLocation = [touch locationInView: [touch view]]; | |
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; | |
CCMenuItem* item; | |
CCARRAY_FOREACH(children_, item){ | |
// ignore invisible and disabled items: issue #779, #866 | |
if ( [item visible] && [item isEnabled] ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CCNode *background = ...; // your complex hierarchy of nodes | |
// Create the NodeRenderer | |
NodeRenderer *renderer = [NodeRenderer renderTextureWithNode:background width:winSize.width height:winSize.height]; | |
// Add it to your scene | |
renderer.position = ccp(winSize.width/2, winSize.height/2); | |
[scene addChild:renderer]; | |
// Fading out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NodeRenderer : CCRenderTexture | |
+(id)renderTextureWithNode:(CCNode*)node width:(int)w height:(int)h; | |
-(id) initWithNode:(CCNode*)n width:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format depthStencilFormat:(GLuint)depthStencilFormat; | |
@end |