Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-23-2011, 08:39 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default 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.
TelTikky is offline   Reply With Quote
Old 08-23-2011, 08:51 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default

Nevermind, typo
TelTikky is offline   Reply With Quote
Old 08-23-2011, 09:23 AM   #3 (permalink)
***
 
huvan's Avatar
 
Join Date: May 2011
Location: Ho Chi Minh
Age: 25
Posts: 23
huvan is on a distinguished road
Default

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
huvan is offline   Reply With Quote
Old 08-23-2011, 09:27 AM   #4 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default

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];
TelTikky is offline   Reply With Quote
Old 08-23-2011, 10:50 AM   #5 (permalink)
***
 
huvan's Avatar
 
Join Date: May 2011
Location: Ho Chi Minh
Age: 25
Posts: 23
huvan is on a distinguished road
Default

ccc3(0, 0, 0) is black. It's same with background color. You try to change to ccc3(255, 255, 255) (white)
__________________
Daniel
huvan is offline   Reply With Quote
Old 08-23-2011, 08:31 PM   #6 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 114
TelTikky is on a distinguished road
Default

Quote:
Originally Posted by huvan View Post
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.
TelTikky is offline   Reply With Quote
Old 08-23-2011, 08:44 PM   #7 (permalink)
***
 
huvan's Avatar
 
Join Date: May 2011
Location: Ho Chi Minh
Age: 25
Posts: 23
huvan is on a distinguished road
Default

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.
huvan is offline   Reply With Quote
Old 09-09-2011, 10:52 PM   #8 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 1
charliemagna is on a distinguished road
Default Hi Van

Quote:
Originally Posted by huvan View Post
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
charliemagna is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:13 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0