17053

score label display value overwrites

Question:

When THE score updates, a new score value label overwrites old one on the display, because of this score is just unreadable, how to update new score? here what i got:

SKLabelNode *ScoreLabel; NSInteger score = 0; ----------------------------- -(void)Scoring{ score = score +1; ScoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; ScoreLabel.position = CGPointMake(CGRectGetMidX(self.frame), 960); ScoreLabel.text = [NSString stringWithFormat:@"%ld",(long)score]; [self addChild:ScoreLabel]; }

Answer1:

You are adding every time the score changes a new label on top. Change the code like this:

-(void)Scoring{ score = score +1; if (ScoreLabel == nil) { ScoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; ScoreLabel.position = CGPointMake(CGRectGetMidX(self.frame), 960); [self addChild:ScoreLabel]; } ScoreLabel.text = [NSString stringWithFormat:@"%ld",(long)score]; }

Recommend

  • negative value for “mean_squared_error”
  • ElasticSearch taking word order into account in match query
  • How do I alternate letter colors on a webpage using javascript?
  • drop down menu width arrangement
  • Doesn't recognize some labels
  • Kivy Update Dynamic Label Text
  • Win API Aligning text on a button
  • Testing a page using AngularJS's routing
  • Why isn't my form submit button not going to a next page when I click on it?
  • C# get font from postscript name
  • Overriding implicit styles in nested controls
  • How to print plain text using Monodevelop and C#?
  • do I have to release the NSDate in this code below?
  • Paging in Azure search when results have equal scores
  • Direction of target annotation when outside of visible area
  • Why is my image being distorted (shrunk) in Firefox?
  • How to center a element in IE6
  • How do I draw a text in openGL/java?
  • Badge value on “More” tab
  • ASP.NET How do I set the position of a control at runtime?
  • Elasticsearch: How to only return results for text search query if the query contains all of the wor
  • How to display a smoother gradient in HTML5 canvas?
  • ingenious idea needed: how to declare different sizes for different fonts? @font-face?
  • access an alertView's calling view
  • How to find the distance (in pixels) between the Sprite and screen corners?
  • what can i do if for loop repeat single row from mysql database?
  • CSS Local Font not showing up
  • Toggle visibility of text box based on status of check box -jQuery
  • Fade Background but NOT Text
  • Imagemagick set interline spacing?
  • how to save the state in userdefaults of accessory checkmark-iphone
  • Blackberry - Custom EditField Cursor
  • Body moving without any force applied? (Box2d)
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Android Google Maps API OnLocationChanged only called once
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?