Skip to content

Instantly share code, notes, and snippets.

@cemolcay
Created June 27, 2014 15:26
Show Gist options
  • Save cemolcay/b9978f3c42ede52886ea to your computer and use it in GitHub Desktop.
Save cemolcay/b9978f3c42ede52886ea to your computer and use it in GitHub Desktop.
- (CCSprite*)spriteWithSize:(CGSize)size andColor:(ccColor4B)color
{
CCSprite *sprite = [CCSprite node];
GLubyte *buffer = malloc(sizeof(GLubyte)*4);
for (int i=0;i<4;i++) {buffer[i]=255;}
CCTexture *tex = [[CCTexture alloc] initWithData:buffer pixelFormat:CCTexturePixelFormat_RGBA4444 pixelsWide:1 pixelsHigh:1 contentSizeInPixels:size contentScale:1];
[sprite setTexture:tex];
[sprite setTextureRect:CGRectMake(0, 0, size.width, size.height)];
free(buffer);
[sprite setColor:[CCColor colorWithCcColor4b:color]];
return sprite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment