diff options
Diffstat (limited to 'libs/cocos2d/notificationDesign.m')
| -rw-r--r-- | libs/cocos2d/notificationDesign.m | 82 |
1 files changed, 82 insertions, 0 deletions
| diff --git a/libs/cocos2d/notificationDesign.m b/libs/cocos2d/notificationDesign.m new file mode 100644 index 0000000..470d402 --- /dev/null +++ b/libs/cocos2d/notificationDesign.m | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* | ||
| 2 | * CCNotifications | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 ForzeField Studios S.L. | ||
| 5 | * http://forzefield.com | ||
| 6 | * | ||
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 8 | * of this software and associated documentation files (the "Software"), to deal | ||
| 9 | * in the Software without restriction, including without limitation the rights | ||
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 11 | * copies of the Software, and to permit persons to whom the Software is | ||
| 12 | * furnished to do so, subject to the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice shall be included in | ||
| 15 | * all copies or substantial portions of the Software. | ||
| 16 | * | ||
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 23 | * THE SOFTWARE. | ||
| 24 | * | ||
| 25 | */ | ||
| 26 | |||
| 27 | |||
| 28 | #import "notificationDesign.h" | ||
| 29 | |||
| 30 | @implementation CCNotificationDefaultDesign | ||
| 31 | |||
| 32 | - (id) init | ||
| 33 | { | ||
| 34 | CGSize size = CGSizeMake(480,320); | ||
| 35 | self = [self initWithColor:ccc4(42, 68, 148, 180) width:size.width height:38]; | ||
| 36 | if (self != nil) { | ||
| 37 | title_ = [CCLabelTTF labelWithString:@" " fontName:@"Arial" fontSize:12]; | ||
| 38 | [title_ setIsRelativeAnchorPoint:NO]; | ||
| 39 | [title_ setAnchorPoint:CGPointZero]; | ||
| 40 | [title_ setPosition:ccp(52, 20)]; | ||
| 41 | |||
| 42 | message_ = [CCLabelTTF labelWithString:@" " fontName:@"Arial" fontSize:15]; | ||
| 43 | [message_ setIsRelativeAnchorPoint:NO]; | ||
| 44 | [message_ setAnchorPoint:CGPointZero]; | ||
| 45 | [message_ setPosition:ccp(52, 3)]; | ||
| 46 | |||
| 47 | image_ = [CCSprite node]; | ||
| 48 | [image_ setPosition:ccp(26, 19)]; | ||
| 49 | |||
| 50 | [self addChild:title_]; | ||
| 51 | [self addChild:message_]; | ||
| 52 | [self addChild:image_]; | ||
| 53 | } | ||
| 54 | return self; | ||
| 55 | } | ||
| 56 | |||
| 57 | - (void) setTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture{ | ||
| 58 | [title_ setString:title]; | ||
| 59 | [message_ setString:message]; | ||
| 60 | if(texture){ | ||
| 61 | CGRect rect = CGRectZero; | ||
| 62 | rect.size = texture.contentSize; | ||
| 63 | [image_ setTexture:texture]; | ||
| 64 | [image_ setTextureRect:rect]; | ||
| 65 | //Same size 32x32 | ||
| 66 | [image_ setScaleX:32.0f/rect.size.width]; | ||
| 67 | [image_ setScaleY:32.0f/rect.size.height]; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | - (void) updateColor | ||
| 72 | { | ||
| 73 | //Gradient code | ||
| 74 | ccColor3B colorFinal = ccc3(0, 50, 100); | ||
| 75 | |||
| 76 | squareColors_[0] = ccc4(color_.r, color_.g, color_.b, opacity_); | ||
| 77 | squareColors_[1] = ccc4(color_.r, color_.g, color_.b, opacity_); | ||
| 78 | squareColors_[2] = ccc4(colorFinal.r, colorFinal.g, colorFinal.b, opacity_); | ||
| 79 | squareColors_[3] = ccc4(colorFinal.r, colorFinal.g, colorFinal.b, opacity_); | ||
| 80 | } | ||
| 81 | |||
| 82 | @end \ No newline at end of file | ||
