08-23-2011, 08:39 AM
#1 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 114
Initialize CCLabelTTF crashes app
I am trying to display score using CCLabelTTF, but my app crashes when I try to initialize the label variable. Did anyone ever have the same problem or have a clue on how to solve this problem?
The code I used is this:
Code:
scoreLabel = [CCLabelTTF labelWithString: [NSString stringWithFormat:@"%d", score]
dimensions: CGSizeMake(180, 20) alignment: UITextAlignmentRight fontName:@"Arial" fontSize: 12];
[scoreLabel setPosition: ccp(10,460)];
[self addchild: scoreLabel];
declaration in header file:
Code:
CCLabelTTF *scoreLabel;
...
@property (nonatomic, retain) CCLabelTTF *scoreLabel;
Thanks in advance.
08-23-2011, 08:51 AM
#2 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 114
Nevermind, typo
08-23-2011, 09:23 AM
#3 (permalink )
***
Join Date: May 2011
Location: Ho Chi Minh
Age: 25
Posts: 23
I guest error at [NSString stringWithFormat:@"%d", score]
If the type of score is double then you should use [NSString stringWithFormat:@"%e", score] .
Good luck!
__________________
Daniel
08-23-2011, 09:27 AM
#4 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 114
Thanks for your reply. Anyways that problem was solved. Now here is the weird one. My app does not crash, but neither is my CCLabelTTF showing.
Here is my latest code, I have tried to change the default color, to no avail ...
Code:
scoreLabel = [CCLabelTTF labelWithString: [NSString stringWithFormat:@"%d", score]
dimensions: CGSizeMake(20, 20) alignment: UITextAlignmentRight fontName:@"Arial" fontSize: 25];
scoreLabel.position = ccp(50, 300);
scoreLabel.color = ccc3(0,0,0);
[self addChild: scoreLabel];
08-23-2011, 10:50 AM
#5 (permalink )
***
Join Date: May 2011
Location: Ho Chi Minh
Age: 25
Posts: 23
ccc3(0, 0, 0) is black. It's same with background color. You try to change to ccc3(255, 255, 255) (white)
__________________
Daniel
08-23-2011, 08:31 PM
#6 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 114
Quote:
Originally Posted by
huvan
ccc3(0, 0, 0) is black. It's same with background color. You try to change to ccc3(255, 255, 255) (white)
Thanks for the reply.
My background is actually blue so black should stand out.
I am trying to bring the score label to the front by adding:
[self addChild: scoreLabel z:10];
But it is still not showing.
08-23-2011, 08:44 PM
#7 (permalink )
***
Join Date: May 2011
Location: Ho Chi Minh
Age: 25
Posts: 23
You try to change CGSizeMake(20, 20 ) to CGSizeMake(100, 100 )
Good luck;
__________________
Daniel
Last edited by huvan; 08-23-2011 at 08:49 PM .
09-09-2011, 10:52 PM
#8 (permalink )
Registered Member
Join Date: Sep 2011
Posts: 1
Hi Van
Quote:
Originally Posted by
huvan
You try to change CGSizeMake(20, 20 ) to CGSizeMake(100, 100 )
Good luck;
Dear Van Do,
Do you do development in HCM? If so please email my friend who is there now:
quocle@gmail.com . Thanks - Mike
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 399
13 members and 386 guests
7twenty7 , cristofercolmbos , dedeys78 , fiftysixty , gmarro , iOS.Lover , jonathandeknudt , Matrix23 , raymng , stanny , tymex , UMAD , xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78