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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:15:40+00:00 2026-06-03T06:15:40+00:00

Hi, i am new to cocos2dx programming…….. I am trying to make a projectile

  • 0

Hi, i am new to cocos2dx programming……..

I am trying to make a projectile motion of a target sprite

// in addtarget() part

int i(0);
while(i<20)
{
p=HelloWorld::nextPoint(p,0.5);//p is a struct see below.

cocos2d::CCFiniteTimeAction* actionMove=cocos2d::CCMoveTo::actionWithDuration(1.0, ccp(p.x,p.y));
target->runAction( cocos2d::CCSequence::actions(actionMove,NULL));
++i;
}
cocos2d::CCFiniteTimeAction* actionMoveDone = cocos2d::CCCallFuncN::actionWithTarget( this,callfuncN_selector(HelloWorld::spriteMoveFinished));

target->runAction( cocos2d::CCSequence::actions(actionMoveDone, NULL) );

nextPoint is a function which returns struct p(which have time,velocity and space coordinates t,x,y,vx,vy)
When outside the loop, it runs all fine but when inside it doesn’t show anything
debugging done and all cordinates are fine
Tried removing NUll can’t do
Finally using bezier so now it works partially.
But unable to understand why CCMoveTo doesn’t work. it always showed initial coordinates of (60,60)
& also some good tutorial link for cocos 2dx for people who r new to mobile game programming. 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-03T06:15:41+00:00Added an answer on June 3, 2026 at 6:15 am

    I am not completely sure that it makes sense running multiple MoveTo actions on the same target. Indeed, you are saying to the same target to move at different locations at the same time, this cannot produce any reliable result.

    You could try using MoveBy, where you specify an incremental displacement, but most probably you will need to rework the logic of your code, if what you want is that you target follows a given trajectory. In this case, you could create a larger sequence containing all of the MoveTo actions you need to run. E.g. (in pseudo code):

     cocos2d::CCSequence* actionSequence = <create empty sequence>;
     while(i<20)
     {
         p = HelloWorld::nextPoint(p,0.5);
         cocos2d::CCFiniteTimeAction* actionMove = ...
         <add actionMove to actionSequence>
         ++i;
     }
    
     target->runAction(actionSequence);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to all this so forgive my ignorance. I am trying to figure out
I'm rather new to serious programming, so please forgive my dumbness, but I've failed
im new to programming, i have been experimenting with cocos2d, heres the problem, i
I am new to opengl programming, but I am doing something very basic, and
I'm trying to create a rotatable sprite. The rotation will be controlled by a
I'm new to game programming. And i have a question. I want to have
I'm relatively new to iphone programming, and I've been starting out with cocos2d. I
I'm fairly new to game programming (but not to programming) and I want to
I have just downloaded the brand new cocos2d 1.01, and I am trying to
I am a programmer new in iphone development. I want to make a game

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.