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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:53:24+00:00 2026-05-20T17:53:24+00:00

I am making a game. I would like to have a joystick that moves

  • 0

I am making a game. I would like to have a joystick that moves the character around the screen. Kinda like a video game controller. Any help would be greatly appreciated! Thanks!

Here is what I am currently using, guys. From looking at it, I don’t think that it generates an input:

-(id) init
{


if( (self=[super initWithColor:ccc4(255,255,255,255)] )) {
    self.isTouchEnabled = YES;

    SneakyJoystickSkinnedBase *leftJoy = [[[SneakyJoystickSkinnedBase alloc] init] autorelease];
    leftJoy.position = ccp(72,72);
    leftJoy.backgroundSprite = [CCSprite spriteWithFile:@"dpad.png"];
    leftJoy.thumbSprite = [CCSprite spriteWithFile:@"joystick.png"];
    leftJoy.joystick = [[SneakyJoystick alloc] initWithRect:CGRectMake(0,0,128,128)];
    leftJoyStick = [leftJoy.joystick retain];
    [self addChild:leftJoy];

    [[CCDirector sharedDirector] setAnimationInterval:1.0f/60.0f];

}
return self;

}

  • 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-20T17:53:25+00:00Added an answer on May 20, 2026 at 5:53 pm

    You can get direction and speed from the vector produced by the joystick. Usually, joystick input generates normalized 2d position whose x and y values are between -1 and 1. For example, Up is (0, 1.0), Right is (0, 1.0), Left is (-1.0, 0) and Down is (0, -1.0). Once you have this input vector, you can get the two values.

    direction = normalize( input_vector );
    speed = length( input_vector ) * SCALE_CONSTANT; 
    // SCALE_CONSTANT is a custom value to get a  real speed. 
    
    1. Set your character’s look-at vector (it is a normalized vector representing character’s current direction) to direction. If you want to rotate the character smoothly, do interpolation from the current look-at vector to direction in your update.

    2. Update your character’s position with the speed

      new_position = current_position + look-at * speed * time;

    You can see there are two movements, rotating and forwarding. People usually set two different speed constants to control them. You can also do one at a time like rotating first and then forwarding. Good Luck! 🙂

    [UPDATE]

    Well, if you don’t want to rotate it, you can just do step 2 with “direction” instead of “look-at”. Also, you can produce “input vector” by subtracting the center position of the joystick from the actual movement (I assume this is a position from the joystick) and then, normalize it.

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

Sidebar

Related Questions

I'm making a game and would like to have a background loop of game
I'm making a chess game and I would like to have an array of
I built a slideshow/decision-making game in Flash but would like to try to redo
I am making a small game in flash, I would like to track scores
I am making simple graphical game in WinForms and currently I would like to
I would like to have a go at making some simple games for personal/learning
I'm making a game where I have must have some objects like weapons and
I am making a racing game and I would like to print some information
I'm making a game with cocos2d and I have a bunch of sprites that
I am making a pokemon like game that will utilize SQLite DBs for storage

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.