Created
June 27, 2014 15:26
-
-
Save cemolcay/b9978f3c42ede52886ea to your computer and use it in GitHub Desktop.
This file contains 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*)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