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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:04:28+00:00 2026-06-04T17:04:28+00:00

so I have a ball (sprite subclass) that can be dragged around the screen

  • 0

so I have a ball (sprite subclass) that can be dragged around the screen and updates it body to tell the world its position.

The problem is, when I apply a force to the ball while the ball is being touched (thus being controlled by a finger), I have two pieces of code fighting against each other to update the sprite’s visual position.

The world stepper is trying to follow through the physics and update the ball’s position. The touch methods however are also trying to update the ball’s body and graphic position. Ideally, when touched I would like to kill off any physics affecting the ball.

So what exactly should I be trying to do to consolidate this? This is also creating issues for collisions and filtering. Any help appreciated. Thanks

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

    Do you want the ball to have an accurate physics simulation? If not, you could always use the SetTransform method of the b2body class like this.

        CGPoint ballLocation = ;//use the touched location for this
        b2Vec2 vecBallLocation = b2Vec2(ballLocation.x / 32, ballLocation.y / 32);//calculate this on your own
        b2Body * ballBody = ;//replace this variable with your ball's b2Body;
        ballBody->SetTransform(vecBallLocation, ballBody->GetAngle());
    

    Do not set the ball sprite’s position manually. Leave this up to the physics simulation. Your code will get really messy over time if you have to keep track of what sprites you set the position of manually and which ones use the physics simulation to update their positions. This way is also much easier.

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

Sidebar

Related Questions

I have a ball moving around the screen, position updated on ENTER_FRAME. My problem
I have a ball (a dynamic body in the shape of a circle) that
I have a sprite(image of a ball) I can move it using touch and
I have a ball sprite that changes it's texture when a certain scenario occurs.
I have a ball that triggers an action when it collides with a sprite.
I'm using AndEngine/Box2d to develop a game. I have a ball that bounces around
I have a ball bouncing around the screen and I need to write code
I have a class called Sprite, and ballSprite is an instance of that class.
I have an Object, Ball, which belongs_to a Girl, which can have_many balls. Everything
I have set of players, and a ball, the players can kick the ball

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.