Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:08:47+00:00 2026-06-14T03:08:47+00:00

I am making a game with cocos2d and would like to implement a progress

  • 0

I am making a game with cocos2d and would like to implement a progress bar to represent my player’s health. I have referenced how to create a progressbar programmatically but a CCLayer does not have a .view attribute. Can someone please point me in the right direction or help me out?

Thank you,
Joey

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:08:49+00:00Added an answer on June 14, 2026 at 3:08 am

    Grab the following image: https://i.stack.imgur.com/O5DRf.png. It is 2×30. I want to make a bar that is 15 pixels high. Normally, the dimensions would be 1×15, but since I assume you’re working with retina display, we have to double such dimensions to 2×30.

    Create a CCSprite with it, and set the anchor point to ccp(0.0,0.5):

    CCSprite *bar = [CCSprite spriteWithFile:@"MyBar.png"];   // Create it
    bar.position = ccp(240,160);                                // Position it
    bar.anchorPoint = ccp(0.0,0.5);                           // Anchor point
    

    Now the question is, how long (max) is the health bar? Let us say it is 200 pixels long. Therefore, 100% = 200 pixels long. Let us set it to 200 pixels long then:

    bar.scaleX = 200;    // The bar is 200 pixels long now
    

    So, how about 50% of health? Then, clearly, the property .scaleX should be 100.

    bar.scaleX = 100;    // The bar is 100 pixels long now (50% health)
    

    That is pretty much all you might need to create a simple bar quickly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a health bar for a battle scene in a game with cocos2d.
I'm making a simple cocos2d adventure game, but have no clue how to implement
I built a slideshow/decision-making game in Flash but would like to try to redo
I'm making an iPhone game in cocos2d. I was wondering how I would make
I'm making a game on iPhone using cocos2d, and I have a question. In
In a game that I am making whilst using Cocos2d, I have a sprite
I'm making a game with cocos2d and I have a bunch of sprites that
I am brand new to Cocos2d and have begun making a simple card game.
my problem is: I'm making a game for iOS using cocos2d and this game
I am making a game in java and I want to create a simulation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.