I am wondering is it possible to make an alert or pop up window with cocos2d, any ideas?
alert or pop up window
(19 posts) (11 voices)-
Posted 2 years ago #
-
You mean using an UIAlertView or making one out of sprites? Either way the answer is yes!
Posted 2 years ago # -
thanks for your reply!
Posted 2 years ago # -
this is the code I use to display a UIAlert
-(void)newLocalScore { UIAlertView* dialog = [[UIAlertView alloc] init]; [dialog setDelegate:self]; [dialog setTitle:@"Online Access"]; [dialog setMessage:@"Do you want to connect to the online ranking?"]; [dialog addButtonWithTitle:@"Yes"]; [dialog addButtonWithTitle:@"No"]; [dialog show]; [dialog release]; } - (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex { if(buttonIndex==0) { //do stuff } }hope that helps
`
Posted 2 years ago # -
that's really helpful, thanks very much!
Posted 2 years ago # -
Is this a legal way accepted by Apple to create alert views?
Posted 1 year ago # -
ehm......yes of course
you can see it here in the documentation
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.htmlPosted 1 year ago # -
I'm sorry, I think I was thinking one thing and reading another. I meant are we allowed to add text fields to these alert views legally?
Posted 1 year ago # -
yes, you are allowed to do it (with addsubview), but not using private api.
Posted 1 year ago # -
I made a "CCAlertView" class, it doesn't have all the regular UIAlertview bells and whistles, but is completely functional for my needs, it has a realistic bounce in action applied to it, enjoy:
(You'll need to supply the alertview background image and button images as well as alert.caf, I can share mine if you like)
// // CCAlertView.h // myApp // // Created by Harvey Mills on 2/16/11. // Copyright 2011 __2BPM Software__. All rights reserved. // #import <Foundation/Foundation.h> #import "cocos2d.h" #import "SimpleAudioEngine.h" @interface CCAlertView : CCLayer { NSString *Message; NSString *SubMessage; NSString *Button1; NSString *Button2; } @property (nonatomic, retain) NSString *Message; @property (nonatomic, retain) NSString *SubMessage; @property (nonatomic, retain) NSString *Button1; @property (nonatomic, retain) NSString *Button2; @end// // CCAlertView.m // myApp // // Created by Harvey Mills on 2/16/11. // Copyright 2011 __2BPM Software__. All rights reserved. // #import "CCAlertView.h" #import "Game.h" @implementation CCAlertView @synthesize Message, SubMessage, Button1, Button2; -(id) init { if((self == [super init])) { self.isTouchEnabled = YES; CCSprite *alertViewSprite = [CCSprite spriteWithFile:@"redalertview.png"]; [self addChild:alertViewSprite z:-1]; // 287X139 CGSize size = CGSizeMake(287, 139); self.anchorPoint = ccp(0,0); Message = @"Do You Want to Try Again?"; SubMessage = @"All Game Data Will Be Reset!"; Button1 = @"OK"; Button2 = @"Cancel"; CCMenuItemImage *OK = [CCMenuItemImage itemFromNormalImage:@"redlightButton.png" selectedImage:@"reddarkButton.png" target:self selector:@selector(resume:)]; CCMenuItemImage *Cancel = [CCMenuItemImage itemFromNormalImage:@"reddarkButton.png" selectedImage:@"redlightButton.png" target:self selector:@selector(cancel:)]; CCMenu *alertMenu = [CCMenu menuWithItems:Cancel, OK, nil]; //alertMenu.anchorPoint = ccp(0,0); [alertMenu alignItemsHorizontallyWithPadding:10]; alertMenu.position = ccp(size.width/2, size.height/2-30); [alertViewSprite addChild:alertMenu]; CCLabelTTF *MessageLabel = [CCLabelTTF labelWithString:Message fontName:@"HelveticaNeue-Bold" fontSize:18]; MessageLabel.position = ccp(alertViewSprite.contentSize.width/2, alertViewSprite.contentSize.height-20); [alertViewSprite addChild:MessageLabel]; CCLabelTTF *SubMessageLabel = [CCLabelTTF labelWithString:SubMessage fontName:@"HelveticaNeue-Bold" fontSize:14]; SubMessageLabel.position = ccp(alertViewSprite.contentSize.width/2, alertViewSprite.contentSize.height-50); [alertViewSprite addChild:SubMessageLabel]; CCLabelTTF *OKlabel = [CCLabelTTF labelWithString:Button1 fontName:@"HelveticaNeue-Bold" fontSize:18]; OKlabel.position = ccp(OK.contentSize.width/2, OK.contentSize.height/2); [OK addChild:OKlabel]; CCLabelTTF *cancellabel = [CCLabelTTF labelWithString:Button2 fontName:@"HelveticaNeue-Bold" fontSize:18]; cancellabel.position = ccp(Cancel.contentSize.width/2, Cancel.contentSize.height/2); [Cancel addChild:cancellabel]; alertViewSprite.scale = .6; alertViewSprite.opacity = 150; id fadeIn = [CCFadeIn actionWithDuration:0.1]; id scale1 = [CCSpawn actions:fadeIn, [CCScaleTo actionWithDuration:0.15 scale:1.1], nil]; id scale2 = [CCScaleTo actionWithDuration:0.1 scale:0.9]; id scale3 = [CCScaleTo actionWithDuration:0.05 scale:1.0]; id pulse = [CCSequence actions:scale1, scale2, scale3, nil]; [alertViewSprite runAction:pulse]; [[SimpleAudioEngine sharedEngine] playEffect:@"alert.caf"]; } return self; } -(void) resume:(id) sender { [[CCDirector sharedDirector] replaceScene: [CCTransitionFade transitionWithDuration:1.0 scene: [Game scene] withColor:ccBLACK]]; } -(void) cancel:(id) sender { CCScene *scene = [[CCDirector sharedDirector] runningScene]; [scene removeChild:self cleanup:YES]; } @endInitialization:
CCAlertView *alertView = [[CCAlertView alloc] init]; alertView.isRelativeAnchorPoint = YES; alertView.position = ccp(self.contentSize.width/2, self.contentSize.height/2); [self.parent addChild:alertView z:1001 tag:kTagAlertView];This could be cleaned up a bit and made a little easier to implement and should probably be derived from a CCSprite, but it works for me. If someone plays with it, let me know. :)
Posted 1 year ago # -
I played with it... here is the updated code.
// // CCAlertView.h // myApp // // Created by Harvey Mills on 2/16/11. // Copyright 2011 __2BPM Software__. All rights reserved. // #import <Foundation/Foundation.h> #import "cocos2d.h" @interface CCAlertView : CCLayer { NSString *Message; NSString *SubMessage; NSString *Button1; NSString *Button2; CCSprite *alertViewSprite; CCLabelTTF *MessageLabel; CCLabelTTF *SubMessageLabel; CCMenuItemFont *OK; CCMenuItemFont *Cancel; id button1Target; SEL button1Selector; id button2Target; SEL button2Selector; } @property (nonatomic, retain) NSString *Message; @property (nonatomic, retain) NSString *SubMessage; @property (nonatomic, retain) NSString *Button1; @property (nonatomic, retain) NSString *Button2; @property (nonatomic, retain) id button1Target; @property (nonatomic) SEL button1Selector; @property (nonatomic, retain) id button2Target; @property (nonatomic) SEL button2Selector; @end// // CCAlertView.m // myApp // // Created by Harvey Mills on 2/16/11. // Copyright 2011 __2BPM Software__. All rights reserved. // #import "CCAlertView.h" #import "Game.h" #import "GameConfig.h" #import "CCMenuItemFontWithStroke.h" #import "CCLabelTTFWithStroke.h" #define FONTNAME @"HelveticaNeue-Bold" @implementation CCAlertView @synthesize Message, SubMessage, Button1, Button2, button1Target, button1Selector, button2Target, button2Selector; -(id) init { if((self == [super init])) { self.isTouchEnabled = YES; //tODO alertViewSprite = [CCSprite spriteWithFile:@"pn.png"]; [self addChild:alertViewSprite z:-1]; // 287X139 //CGSize size = CGSizeMake(287, 139); CGSize size = alertViewSprite.contentSize; self.anchorPoint = ccp(0,0); //self.Message = @"Do You Want to Try Again?"; //self.SubMessage = @"All Game Data Will Be Reset!"; Button1 = @"Okay"; Button2 = @"Cancel"; NSString * previousFontName = [CCMenuItemFont fontName]; int previousFontSize = [CCMenuItemFont fontSize]; [CCMenuItemFont setFontName:FONTNAME]; [CCMenuItemFont setFontSize:18]; OK = [CCMenuItemFontWithStroke itemFromString:Button1 target:self selector:@selector(buttonOneClicked:)]; Cancel = [CCMenuItemFontWithStroke itemFromString:Button2 target:self selector:@selector(buttonTwoClicked:)]; [CCMenuItemFont setFontName:previousFontName]; [CCMenuItemFont setFontSize:previousFontSize]; OK.anchorPoint = ccp(.5,0); Cancel.anchorPoint = ccp(.5,0); CCMenu *alertMenu = [CCMenu menuWithItems:Cancel, OK, nil]; alertMenu.anchorPoint = ccp(.5,0); [alertMenu alignItemsHorizontallyWithPadding:10]; alertMenu.position = ccp(size.width/2, 0); [alertViewSprite addChild:alertMenu]; alertViewSprite.scale = .6; alertViewSprite.opacity = 150; id fadeIn = [CCFadeIn actionWithDuration:0.1]; id scale1 = [CCSpawn actions:fadeIn, [CCScaleTo actionWithDuration:0.15 scale:1.1], nil]; id scale2 = [CCScaleTo actionWithDuration:0.1 scale:0.9]; id scale3 = [CCScaleTo actionWithDuration:0.05 scale:1.0]; id pulse = [CCSequence actions:scale1, scale2, scale3, nil]; [alertViewSprite runAction:pulse]; } return self; } -(void) buttonOneClicked:(id) sender { [self removeFromParentAndCleanup:YES]; NSMethodSignature * sig = nil; if( button1Target && button1Selector ) { sig = [button1Target methodSignatureForSelector:button1Selector]; NSInvocation *invocation = nil; invocation = [NSInvocation invocationWithMethodSignature:sig]; [invocation setTarget:button1Target]; [invocation setSelector:button1Selector]; #if NS_BLOCKS_AVAILABLE if ([sig numberOfArguments] == 3) #endif [invocation setArgument:&self atIndex:2]; [invocation invoke]; } } -(void) buttonTwoClicked:(id) sender { [self removeFromParentAndCleanup:YES]; NSMethodSignature * sig = nil; if( button2Target && button2Selector ) { sig = [button2Target methodSignatureForSelector:button2Selector]; NSInvocation *invocation = nil; invocation = [NSInvocation invocationWithMethodSignature:sig]; [invocation setTarget:button2Target]; [invocation setSelector:button2Selector]; #if NS_BLOCKS_AVAILABLE if ([sig numberOfArguments] == 3) #endif [invocation setArgument:&self atIndex:2]; [invocation invoke]; } } -(void)setMessage:(NSString *)Message_{ if (Message == nil) { [MessageLabel removeFromParentAndCleanup:YES]; } [Message release]; Message = [Message_ retain]; if (Message_ != nil) { MessageLabel = [CCLabelTTFWithStroke labelWithString:Message fontName:FONTNAME fontSize:18 strokeSize:1 stokeColor:ccBLACK]; MessageLabel.anchorPoint = ccp(.5,1); MessageLabel.position = ccp(alertViewSprite.contentSize.width/2, alertViewSprite.contentSize.height); [alertViewSprite addChild:MessageLabel]; } } -(void)setSubMessage:(NSString *)SubMessage_{ if (SubMessage == nil) { [SubMessageLabel removeFromParentAndCleanup:YES]; } [SubMessage release]; SubMessage = [SubMessage_ retain]; if (SubMessage_ != nil) { SubMessageLabel = [CCLabelTTFWithStroke labelWithString:SubMessage fontName:FONTNAME fontSize:14 strokeSize:1 stokeColor:ccBLACK]; SubMessageLabel.position = ccp(alertViewSprite.contentSize.width/2, alertViewSprite.contentSize.height/2); [alertViewSprite addChild:SubMessageLabel]; } } -(void)setButton1:(NSString *)Button1_{ if (Button1_ == nil) { Button1 = @" "; }else{ Button1 = [Button1_ retain]; } [OK setString:Button1]; } -(void)setButton2:(NSString *)Button2_{ if (Button2_ == nil) { Button2 = @" "; }else{ Button2 = [Button2_ retain]; } [Cancel setString:Button2]; } @endExample Usage:
CCMenuItemFontWithStroke * quit = [CCMenuItemFontWithStroke itemFromString:@"Quit" block:^(id sender){ if ([defaults boolForKey:PlaySoundEffectsKey]) { [[SimpleAudioEngine sharedEngine] playEffect:MenuClickSound]; } CCAlertView *alertView = [[CCAlertView alloc] init]; alertView.isRelativeAnchorPoint = YES; alertView.position = ccp(self.contentSize.width/2, self.contentSize.height/2); alertView.Message = @"Are you sure?"; alertView.SubMessage = @"Your progress will not be saved."; alertView.Button1 = @"Yes"; alertView.button1Target = self; alertView.button1Selector = @selector(quit:); alertView.Button2 = @"NO"; [self addChild:alertView z:1001]; }];Posted 1 year ago # -
@hm50 Thank you for sharing! Nice animation!
@bobertperry Great modifications! Could you show your implementation of CCLabelTTFWithStroke?Posted 12 months ago # -
Very welcome, glad to help. Also nice fixes @bobertperry !
For anyone inquiring, it has been brought up in another thread, this code (my part) adopts the MIT license. :)
Posted 12 months ago # -
This is a great little class. Thanks @hm50! (and @bobertperry for your improvements). Has anyone else tried the one with FontStroke? I have tried and can get most of it working, but this code is crashing my app:
-(void) buttonOneClicked:(id) sender { [self removeFromParentAndCleanup:YES]; NSMethodSignature * sig = nil; if( button1Target && button1Selector ) { sig = [button1Target methodSignatureForSelector:button1Selector]; NSInvocation *invocation = nil; invocation = [NSInvocation invocationWithMethodSignature:sig]; [invocation setTarget:button1Target]; [invocation setSelector:button1Selector]; #if NS_BLOCKS_AVAILABLE if ([sig numberOfArguments] == 3) #endif [invocation setArgument:&self atIndex:2]; [invocation invoke]; } }I get this in the console:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil' *** Call stack at first throw: ( 0 CoreFoundation 0x33ac0987 __exceptionPreprocess + 114 1 libobjc.A.dylib 0x3347b49d objc_exception_throw + 24 2 CoreFoundation 0x33a6b05d +[NSInvocation invocationWithMethodSignature:] + 340 3 ScoreTrack 0x0000afb4 -[CCAlertView buttonOneClicked:] + 264 4 CoreFoundation 0x33a6bd04 __invoking___ + 68 5 CoreFoundation 0x33a6bbd5 -[NSInvocation invoke] + 108 6 ScoreTrack 0x0006eca8 -[CCMenuItem activate] + 92 7 ScoreTrack 0x0006c350 -[CCMenu ccTouchEnded:withEvent:] + 284 8 CoreFoundation 0x33a67fed -[NSObject(NSObject) performSelector:withObject:withObject:] + 24 9 ScoreTrack 0x000c69bc -[CCTouchDispatcher touches:withEvent:withTouchType:] + 1116 10 ScoreTrack 0x000c7338 -[CCTouchDispatcher touchesEnded:withEvent:] + 116 11 ScoreTrack 0x000c98a0 -[EAGLView touchesEnded:withEvent:] + 116 12 UIKit 0x3207b355 -[UIWindow _sendTouchesForEvent:] + 368 13 UIKit 0x3207accf -[UIWindow sendEvent:] + 262 14 UIKit 0x32065fc7 -[UIApplication sendEvent:] + 298 15 UIKit 0x32065907 _UIApplicationHandleEvent + 5090 16 GraphicsServices 0x33b0ef03 PurpleEventCallback + 666 17 CoreFoundation 0x33a556ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26 18 CoreFoundation 0x33a556c3 __CFRunLoopDoSource1 + 166 19 CoreFoundation 0x33a47f7d __CFRunLoopRun + 520 20 CoreFoundation 0x33a47c87 CFRunLoopRunSpecific + 230 21 CoreFoundation 0x33a47b8f CFRunLoopRunInMode + 58 22 GraphicsServices 0x33b0e4ab GSEventRunModal + 114 23 GraphicsServices 0x33b0e557 GSEventRun + 62 24 UIKit 0x32099329 -[UIApplication _run] + 412 25 UIKit 0x32096e93 UIApplicationMain + 670 26 ScoreTrack 0x00002b10 main + 100 27 ScoreTrack 0x00002a74 start + 52 ) terminate called after throwing an instance of 'NSException' Program received signal: “SIGABRT”.The odd thing is that the Other button code (which is identical but just for button two, works perfectly and dismisses the ccalertview.
*edit
Not sure what all the NSInvocation stuff is doing (i'll need to do some reading!), but removing that from the button one method and leaving in just
[self removeFromParentAndCleanup:YES];removes it as I would expect for the "OK" button, so I'll just play around some more and get it to do what I need... Thanks again guys!
Posted 12 months ago # -
@Shogan NSInvocation stuff is to call your designated function after the button press.
It should be configured properly. Try this:CCAlertView *alertView = [[CCAlertView alloc] init]; alertView.isRelativeAnchorPoint = YES; alertView.position = ccp(self.contentSize.width/2, self.contentSize.height/2); alertView.Message = @"Are you sure?"; alertView.SubMessage = @"Your progress will not be saved."; alertView.Button1 = @"Yes"; alertView.button1Target = self; alertView.button1Selector = @selector(onAlertButtonYes:); // <- funct. for YES alertView.Button2 = @"NO"; [self addChild:alertView z:1001];- (void) onAlertButtonYes:(id) alertView // companion function for YES button { // do something }BTW: How do you implement CCLabelTTFWithStroke?
Posted 12 months ago # -
@cocos, thank you. I see how it works now :) I was just trying to figure out how to call the function in my other class - your explanation made me click.
Regarding the TTFWithStroke, I'm not actually using it - I just changed all the references to it back to CCLabelTTF and took out the header references in the .m file.
So for example I am now using images for the buttons in the alertview instead like this:
OK = [CCMenuItemImage itemFromNormalImage:@"alertok.png" selectedImage:@"alertoks.png" target:self selector:@selector(buttonOneClicked:)]; Cancel = [CCMenuItemImage itemFromNormalImage:@"alertno.png" selectedImage:@"alertnos.png" target:self selector:@selector(buttonTwoClicked:)];and I have changed other stuff like this to normal CCLabelTTF:
SubMessageLabel = [CCLabelTTF labelWithString:SubMessage fontName:FONTNAME fontSize:14];Posted 12 months ago # -
Forgot I used the my stroke wraper. If anyone is curious it's located at another post:
http://www.cocos2d-iphone.org/forum/topic/12126I'll post it here too:
.h
// // CCMenuItemFontWithStroke.h // test2 // // Created by Robert Perry on 2/5/11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import <Foundation/Foundation.h> #import "cocos2d.h" @interface CCMenuItemFontWithStroke : CCMenuItemFont { int stokeSize; ccColor3B strokeColor; } @property (nonatomic) int stokeSize; @property (nonatomic)ccColor3B strokeColor; -(id) initFromString: (NSString*) value target:(id) rec selector:(SEL) cb strokeSize:(int)strokeSize stokeColor:(ccColor3B)color; @end.m
// // CCMenuItemFontWithStroke.m // test2 // // Created by Robert Perry on 2/5/11. // Copyright 2011 __MyCompanyName__. All rights reserved. // #import "CCMenuItemFontWithStroke.h" @implementation CCMenuItemFontWithStroke @synthesize stokeSize; @synthesize strokeColor; #define kTagStroke 1029384756 +(CCRenderTexture*) createStroke: (CCLabelTTF*) label size:(float)size color:(ccColor3B)cor { CCRenderTexture* rt = [CCRenderTexture renderTextureWithWidth:label.texture.contentSize.width+size*2 height:label.texture.contentSize.height+size*2]; CGPoint originalPos = [label position]; ccColor3B originalColor = [label color]; BOOL originalVisibility = [label visible]; [label setColor:cor]; [label setVisible:YES]; ccBlendFunc originalBlend = [label blendFunc]; [label setBlendFunc:(ccBlendFunc) { GL_SRC_ALPHA, GL_ONE }]; CGPoint bottomLeft = ccp(label.texture.contentSize.width * label.anchorPoint.x + size, label.texture.contentSize.height * label.anchorPoint.y + size); //CGPoint positionOffset = ccp(label.texture.contentSize.width * label.anchorPoint.x - label.texture.contentSize.width/2,label.texture.contentSize.height * label.anchorPoint.y - label.texture.contentSize.height/2); //use this for adding stoke to its self... CGPoint positionOffset= ccp(-label.contentSize.width/2,-label.contentSize.height/2); CGPoint position = ccpSub(originalPos, positionOffset); [rt begin]; for (int i=0; i<360; i+=30) // you should optimize that for your needs { [label setPosition:ccp(bottomLeft.x + sin(CC_DEGREES_TO_RADIANS(i))*size, bottomLeft.y + cos(CC_DEGREES_TO_RADIANS(i))*size)]; [label visit]; } [rt end]; [label setPosition:originalPos]; [label setColor:originalColor]; [label setBlendFunc:originalBlend]; [label setVisible:originalVisibility]; [rt setPosition:position]; return rt; } -(id) initFromString: (NSString*) value target:(id) rec selector:(SEL) cb strokeSize:(int)strokeSize stokeColor:(ccColor3B)color { self = [super initFromString:value target:rec selector:cb]; self.strokeColor = color; self.stokeSize = strokeSize; if ([label_ isKindOfClass: [CCLabelTTF class]]) { CCRenderTexture * stroke = [CCMenuItemFontWithStroke createStroke:(CCLabelTTF*)label_ size:strokeSize color:strokeColor]; [self addChild:stroke z:-1 tag:kTagStroke]; }else{ NSLog(@"Error adding stroke in menu, label_ is not a CCLabelTTF. This has only been tested on cocos2d 99.5"); } return self; } //default 1 pixel, black -(id) initFromString: (NSString*) value target:(id) rec selector:(SEL) cb { return [self initFromString:value target:rec selector:cb strokeSize:3 stokeColor:ccBLACK]; } -(void) setString:(NSString *)string { [super setString:string]; if ([label_ isKindOfClass: [CCLabelTTF class]]) { [self removeChildByTag:kTagStroke cleanup:YES]; CCRenderTexture * stroke = [CCMenuItemFontWithStroke createStroke:(CCLabelTTF*)label_ size:stokeSize color:strokeColor]; [self addChild:stroke z:-1 tag:kTagStroke]; }else{ NSLog(@"Error adding stroke in menu, label_ is not a CCLabelTTF. This has only been tested on cocos2d 99.5"); } } @endPosted 11 months ago # -
I ran into an interesting problem using CCAlertView.
I have a layer which is used for a game level. When the player finishes the level, I present a CCAlertView asking whether to continue or quit to the main menu.
It turned out that because the CCAlertView gets added to the layer as a child, the layer has a retained copy of the alertview. But because the alertview is configured to use the layer as a target for the button1 and 2 methods, the alertview has retained a copy of the layer. As a result, my layer was never being deallocated and the game would crash after playing for a bit.
In my specific case, I felt comfortable altering the following two lines in the header from:
@property (nonatomic, retain) id button1Target;
@property (nonatomic, retain) id button2Target;to:
@property (nonatomic, assign) id button1Target;
@property (nonatomic, assign) id button2Target;because I knew that the targets in this case are being handled by cocos2d, thus eliminating my retain loop and allowing the game to work properly. There may be a more elegant solution, perhaps releasing the targets when the buttons are clicked or something, but I took the shortcut in my case.
I hope this is helpful.
Posted 11 months ago # -
Another good modification is to use the new word wrap features of release 1.0.1 in CCLabelTTF to make it a bit easier to get multiline submessage.
-(void)setSubMessage:(NSString *)SubMessage_{ if (SubMessage == nil) { [SubMessageLabel removeFromParentAndCleanup:YES]; } [SubMessage release]; SubMessage = [SubMessage_ retain]; if (SubMessage_ != nil) { //SubMessageLabel = [CCLabelTTFWithStroke labelWithString:SubMessage fontName:FONTNAME fontSize:14 strokeSize:1 stokeColor:ccBLACK]; //SubMessageLabel = [CCLabelTTF labelWithString:SubMessage fontName:FONTNAME fontSize:14]; SubMessageLabel = [CCLabelTTF labelWithString:SubMessage dimensions:CGSizeMake(0.8*alertViewSprite.contentSize.width,alertViewSprite.contentSize.height/2) alignment:CCTextAlignmentCenter lineBreakMode:CCLineBreakModeWordWrap fontName:FONTNAME fontSize:14]; SubMessageLabel.position = ccp(alertViewSprite.contentSize.width/2, alertViewSprite.contentSize.height/2); [alertViewSprite addChild:SubMessageLabel]; } }Posted 8 months ago #
Reply
You must log in to post.