/libs/cocos2d/CCProtocols.h
C Header | 112 lines | 32 code | 13 blank | 67 comment | 0 complexity | d8343a1393c9072ab805b254831ffcdb MD5 | raw file
Possible License(s): Apache-2.0
1/* 2 * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 * 4 * Copyright (c) 2008-2010 Ricardo Quesada 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 26#import "ccTypes.h" 27#import "CCTexture2D.h" 28 29#pragma mark - 30#pragma mark CCRGBAProtocol 31 32/// CC RGBA protocol 33@protocol CCRGBAProtocol <NSObject> 34/** sets Color 35 @since v0.8 36 */ 37-(void) setColor:(ccColor3B)color; 38/** returns the color 39 @since v0.8 40 */ 41-(ccColor3B) color; 42 43/// returns the opacity 44-(GLubyte) opacity; 45/** sets the opacity. 46 @warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed. 47 Values goes from 0 to 255, where 255 means fully opaque. 48 */ 49-(void) setOpacity: (GLubyte) opacity; 50@optional 51/** sets the premultipliedAlphaOpacity property. 52 If set to NO then opacity will be applied as: glColor(R,G,B,opacity); 53 If set to YES then oapcity will be applied as: glColor(opacity, opacity, opacity, opacity ); 54 Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO 55 @since v0.8 56 */ 57-(void) setOpacityModifyRGB:(BOOL)boolean; 58/** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity); 59 @since v0.8 60 */ 61 -(BOOL) doesOpacityModifyRGB; 62@end 63 64#pragma mark - 65#pragma mark CCBlendProtocol 66/** 67 You can specify the blending fuction. 68 @since v0.99.0 69 */ 70@protocol CCBlendProtocol <NSObject> 71/** set the source blending function for the texture */ 72-(void) setBlendFunc:(ccBlendFunc)blendFunc; 73/** returns the blending function used for the texture */ 74-(ccBlendFunc) blendFunc; 75@end 76 77 78#pragma mark - 79#pragma mark CCTextureProtocol 80 81/** CCNode objects that uses a Texture2D to render the images. 82 The texture can have a blending function. 83 If the texture has alpha premultiplied the default blending function is: 84 src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA 85 else 86 src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA 87 But you can change the blending funtion at any time. 88 @since v0.8.0 89 */ 90@protocol CCTextureProtocol <CCBlendProtocol> 91/** returns the used texture */ 92-(CCTexture2D*) texture; 93/** sets a new texture. it will be retained */ 94-(void) setTexture:(CCTexture2D*)texture; 95@end 96 97#pragma mark - 98#pragma mark CCLabelProtocol 99/** Common interface for Labels */ 100@protocol CCLabelProtocol <NSObject> 101/** sets a new label using an NSString */ 102-(void) setString:(NSString*)label; 103 104@optional 105/** sets a new label using a CString. 106 It is faster than setString since it doesn't require to alloc/retain/release an NString object. 107 @since v0.99.0 108 */ 109-(void) setCString:(char*)label; 110@end 111 112