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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:30:37+00:00 2026-06-12T17:30:37+00:00

Hi Raj Thanks for quick response actually what my problem was i have to

  • 0

Hi Raj Thanks for quick response actually what my problem was i have to move a sprite to touch point where ever i touched and also i want to move that sprite along x axis only, for that i use the following code

- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{       
    for( UITouch *touch in touches ) {

    location = [touch locationInView: [touch view]];

    location = [[CCDirector sharedDirector] convertToGL: location];

    for(b2Body *b=world->GetBodyList();b;b=b->GetNext()){

    if(b->GetUserData()!=NULL) {`

    CCSprite *myActor =(CCSprite *)b->GetUserData();

    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);

    b->SetTransform(b2Vec2(locationWorld.x, locationWorld.y),0);


    NSLog(@"x position of baby sprite is %@",  b->GetPosition().x);

    id action = [CCMoveTo actionWithDuration:0.4 position:CGPointMake( b->GetPosition().x, b->GetPosition().y)];

     [myActor runAction:action];

}}}}

with this code am moving my sprite where ever i want but its not restricted to x axis…… So can u please help me regarding this

thanks in advance

  • 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-12T17:30:38+00:00Added an answer on June 12, 2026 at 5:30 pm

    try to use this code:

    - (void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event{
    

    //coordinates of the point where we are touching

    CGPoint tocco = [touch locationInView:[touch view]];
    CGPoint tocco2 = [[CCDirector sharedDirector] convertToGL:tocco];
    

    //action to move the sprite

    id muovi = [CCMoveTo actionWithDuration:1 position:tocco2];
    
    [MySprite runAction:muovi];
    
    //if you want turn the sprite left o right
    if (tocco2.x < MySprite.position.x) {
    
        id sx = [CCFlipX actionWithFlipX:NO];
    
        [MySprite runAction:sx];
    
    }else{
    
        id dx = [CCFlipX actionWithFlipX:YES];
    
        [MySprite runAction:dx];
    
    }
    

    }

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

Sidebar

Related Questions

I have been working around in UIImagePickerController and am struck with a problem where
We currently have a problem whereby on our stage servers, links that exist on
Can anyone provide complete example of Stored Procedure call with Spring framework. Thanks, Raj
I have a list of email address which I want to distribute evenly by
I am getting error in the sql statement. (server= RAJ-PC\SQLEXPRESS; user id=sa; password=as64ws; database=onlineshopping,
I have developed an web application using JSP and deployed in tomcat server. In
I have a requirement of using Three20 in my iPad project. I was wondering
I have a BAT file, which creates a number of csv files by reading
I am struck with a problem. I installed the p12 certificates once into a
I have stored some names and scores in a SQLite Database, as shown in

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.