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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:29:34+00:00 2026-06-06T08:29:34+00:00

I can’t work out how to pass the touch location in touch began into

  • 0

I can’t work out how to pass the touch location in touch began into my method that is ran when touch began starts.

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
[self schedule:@selector(moveSprite:)];
return TRUE;
}

-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
[self unschedule:@selector(moveSprite:)];
}

-(void)moveSprite:(ccTime) delta
{

CGPoint spriteCenter = CGPointMake(player.contentSize.width /2,player.contentSize.height /2);

CGPoint touchPoint; //how to get this touch began?

float distanceX = touchPoint.x - spriteCenter.x;
float distanceY = touchPoint.y - spriteCenter.y;

float angle = atan2f(distanceY,distanceX); // returns angle in radians

player.rotation = angle;

}

I also have a question about [self schedule:@selector: Will this continuously call my move sprite method? As I’m going to want the sprite to continuously move and change rotation accordingly as the touch is held down and the sprites position changes.

My final question is about moving the sprite to the x coordinate of the touch. If I use ccmoveto I can’t use velocity to make the sprite slowly increase its speed can I? How would I move the sprite to the touched point increasing velocity? I’m guessing its something to do with delta.

  • 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-06T08:29:39+00:00Added an answer on June 6, 2026 at 8:29 am

    Actually, I don’t see any need in your scheduled method. You just can implement

    - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
    

    method and place your sprite rotation logic there.

    To get changeable move velocity, you can use one of CCActionEase subclasses. Wrap your move action in one of them and you will see velocity changes during movement. Something like

    id move_ease_in = [CCEaseIn actionWithAction:yourMoveAction rate:3.0f];
    [player runAction: move_ease_in];
    

    you can see few examples here

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

Sidebar

Related Questions

Can anyone explain me what's going on? I use this method - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
Can't work out a way to make an array of buttons in android. This
Can anyone help me trying to find out why this doesn't work. The brushes
Can't figure out how to do this in a pretty way : I have
Can we change the color of the divider? Apple documentations says, that we can
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can't seem to figure out what's wrong with the simple getJSON call below. It's
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Can some one Guide me to work with these things... What is Model popup
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());

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.