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 3602170
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:42:45+00:00 2026-05-18T20:42:45+00:00

I really tried everything: stackoverflow, google, github, cocos2d, everything. Didn’t find anything helpful to

  • 0

I really tried everything:
stackoverflow, google, github, cocos2d, everything.
Didn’t find anything helpful to create a custom slider that looks nice in a GAME, I successfully added a normal UISlider and changed it properties a bit, like maximumValueImage an so on… but it is awful.
PLEASE HELP

  • 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-05-18T20:42:46+00:00Added an answer on May 18, 2026 at 8:42 pm

    If your referring to the “speed” bar in TrainYard, that could be easily achieved by using “state” images for “Press” and “Normal” (like you would a regular button) and then setting a simple “background” image. It’s all in the graphics, more or less.

    Generally speaking, the code would simply check to see if a touch was on the “button” and then would “lock” the Y axis and have the X axis follow the movement. Once the touch is “off the button” by a “factor” in either X or Y you would simply “release” (don’t release when the touch leaves the button at first, give them a window to touch the button that fits it, but give them a much larger window for “releasing” so the “slide” can feel more natural and not require absolute accuracy along the X axis).

    If your “slider button” at “0” is positioned at ccp(25, 15) in relation to the background, and is positioned at ccp(100, 15) at “100” then you you would use the following to determine the “current value” based on the “slider buttons” current position:

    // constants
    #define SLIDER_MIN   0.0f;
    #define SLIDER_MIN_X 25.0f;
    #define SLIDER_MAX   100.0f;
    #define SLIDER_MAX_X 100.0f;
    #define SLIDER_TICKS (SLIDER_MAX_X - SLIDER_MIN_X);
    #define SLIDER_RATIO (SLIDER_TICKS / SLIDER_MAX)
    
    // sliderButton should be a child of a node containing the background
    // it's X/Y should be relative to that parent, and the "slider bar" should
    // either be the parent or be attached to the parent in the same way
    
    // assume: sliderButton.position.x = 63
    float sliderCurrent = sliderButton.position.x - SLIDER_MIN_X;
    // sliderCurrent = 38
    float currentValue = sliderCurrent / SLIDER_RATIO;
    

    This results in the following:

    SLIDER_TICKS = 100 - 25;
    // SLIDER_TICKS = 75
    SLIDER_RATIO = 75 / 100;
    // SLIDER_RATION = .75
    sliderCurrent = 63 - 25;
    // sliderCurrent = 38
    currentValue = 38 / .75
    // currentValue = 50.66666666667
    

    You can then choice to ceil() or floor() this value to get a whole number, or you could just use the value returned (depends on your logic really).

    My suggestion would be to design your artwork so that your “50%” mark is “dead on”. In other words, when you player puts the slider at the 50% section you are able to get a value of “50.0” back from the above code without using ceil() or floor().

    But this is entirely graphic driven … the “press” and “normal” states of the slider button, and the artwork that the “slider button” slides on (the ‘background’) are entirely up to you.

    NOTE: lock the X axis to go no further left or right than is appropriate for your artwork, and lock the Y axis completely, as mention already.

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

Sidebar

Related Questions

I really tried everything: stackoverflow, google, github, cocos2d, everything. Didn't find anything helpful to
The code below is really annoying me I have looked on stackoverflow and google
I have a jQuery problem, and I've really tried everything I know (i am
I can't make this go away and I've tried everything. I don't really care
I've tried everything I can think of and can't get anything to work. I
I really need your help. I tried everything but the result is always the
I really don't understand what the issue is here, I've tried everything I can
Ok, so I've pretty much tried everything. I bet it's something really simple but
What should i use to code Classic ASP under Linux. I have really tried
I've tried using source control for a couple projects but still don't really understand

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.