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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:29:30+00:00 2026-06-07T17:29:30+00:00

I am working on a game which has working similar to game monkey kick

  • 0

I am working on a game which has working similar to game monkey kick off. I have one ball bouncing on a place at the left side of screen and depending upon the position of the ball I apply linearImpulse to the ball on user touch so that it appears that the ball is kicked.
But what happens is when i apply impulse the ball goes out of the screen bounds. I dont want the ball to go out of the horizontal screen bounds whereas it can go out of the screen vertically.I tried using CCFollow but it doesn’t give the realistic feel to the game flow.
I tried THIS tutorial, but dint help much.I managed to scroll the background,Only this part remains.

Any Ideas on how the ball should not move out of the horizontal screen boundary..? but in case of vertical boundary on the other hand it can go out of the bounds.

  • 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-07T17:29:31+00:00Added an answer on June 7, 2026 at 5:29 pm

    If you’re not using physics, it’s a simple bounds check. Assuming the screen width is 320 points this will keep the ball inside the screen horizontally:

    CGPoint ballPos = ball.position;
    ball.position.x = fmaxf(0, fminf(320, ballPos.x));
    ball.position = ballPos;
    

    UPDATE: I noticed you mentioned linear impulse. So you’re using a physics engine. In that case, create a horizontal wall on both sides. See the cocos2d Box2D or Chipmunk templates how to enclose the screen with a collision border, then use only the left and right side borders in your game.

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

Sidebar

Related Questions

I have a game app which is mostly working fine. If a phone call
i am working on voxel based game engine, in which i need to have
I'm working on a multiplayer game which has a lobby-like area where players select
I'm working on a game with finding objects on the screen which has also
I'm working on a game which has tank battles on a tiled map. If
We are working on a game using MonoGame, which has been working fine with
I'm working on a game which has different modules that I am developping on
I'm working on a game, which has score based on a JavaScript countdown: the
I have a Game class that has a -(void) play method which will be
I'm working on a game-like app which has up to a thousand shapes (ellipses

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.