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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:20:50+00:00 2026-06-03T03:20:50+00:00

I want to create a visible object with a trajectory using standard actions (CCMoveBy

  • 0

I want to create a visible object with a trajectory using standard actions (CCMoveBy and e.t.c) which is similar to:

x = sin(y)

My code:

CCMoveBy *moveAction1 = [CCMoveBy actionWithDuration:1.5 position:ccp(300, 0)];
CCEaseInOut *easeInOutAction1 = [CCEaseInOut actionWithAction:moveAction1 rate:2];
CCMoveBy *moveAction2 = [CCMoveBy actionWithDuration:1.5 position:ccp(-300, 0)];
CCEaseInOut *easeInOutAction2 = [CCEaseInOut actionWithAction:moveAction2 rate:2];
CCMoveBy *moveAction3 = [CCMoveBy actionWithDuration:1.5 position:ccp(0, -32)];
CCSpawn *moveActionRight = [CCSpawn actionOne:easeInOutAction1 two:moveAction3];
CCSpawn *moveActionLeft = [CCSpawn actionOne:easeInOutAction2 two:moveAction3];
CCSequence *sequenceOfActions = [CCSequence actionOne:moveActionRight two:moveActionLeft];
CCRepeatForever *finalMoveAction = [CCRepeatForever actionWithAction:sequenceOfActions];
[enemy runAction:finalMoveAction];

This code shows move down only. The problem is that object has a different x and y accelerations and I don’t know how to combine them

UPDATED

- (void)tick:(ccTime)dt
{
    CGPoint pos = self.position;
    pos.y -= 50 * dt;
    if (pos.y < activationDistance) {
        pos.x = 240 + sin(angle) * 140;
        angle += dt * 360 * 0.007;
        if (angle >= 360) {
            angle = ((int)angle) % 360;
        }
    }
    self.position = pos;
}

It is my current solution. I can increase activationDistance to adjust the object trajectory. But I want to setup an initial value of the angle variable.

I use numbers instead of variables because they are used inside this function only.

SOLVED

To change the initial angle:

angle = point.x < 240 ? -asin((240 – point.x) / 140) : asin((point.x – 240) / 140);

the main problem was my tiled map has its own coordinates and cover 320×320 part of the screen only

  • 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-03T03:20:51+00:00Added an answer on June 3, 2026 at 3:20 am

    I think it will be easier for you to just do it in your frame update method (the one I assume you schedule for updating your objects. So why not just do :

    - (void)tick:(ccTime)dt {
       CGPoint pos = myObject.position;
       pos.x = <desired x> + sin(angle);
       pos.y = pos.y - y_acceleration * dt;
       angle += dt * 360 * x_acceleration;
       if (angle >= 360) 
           angle = ((int)angle) % 360;
    
       myObject.position = pos;
    }
    

    And you can apply the same for the y axis of the object

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

Sidebar

Related Questions

I don't want to create an object because it won't affect my visible form.
I dispose a object in my code and I want to now create it
I want create module which update list of usb devices automatically (not only mass
All, I created a plugin using the create plugin with a view wizard, which
I am using Visual C# Winforms to control a WebBrowser object. Specifically I want
I am using the following code and it works fine. protected void Button2_Click(object sender,
I want to create a custom toolbar control (descendant TToolBar) which should have some
How it is possible to create a object and numbering it? I want to
I want create a excel with Apache POI in java and I must insert
i want create image animation , i have 50 images with png format now

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.