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

  • Home
  • SEARCH
  • 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 4052862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:22:24+00:00 2026-05-20T14:22:24+00:00

When sliding sprite, if sprite disappears off the side, i want to make it

  • 0

When sliding sprite, if sprite disappears off the side, i want to make it wrap around to the opposite side but I do not know how to do this while the sprite is simultaneously being pushed off one side i want the other bit that you can’t see to appear on the opposite side like a loop some sort of wormhole thing.

here is my code so far but it crashes and it only transports the sprite once the whole of the sprite disappears of the side. Loop also needs to run as an infinite loop until someone quits the app.

        for (int i =0; i<16; ++i) {
        MyNode *currentSprite = [c1array objectAtIndex:i];
        if (currentSprite.contentSize.height>=320 || currentSprite.position.y-currentSprite.contentSize.height/2<=0 ){
            MyNode *Bsprite = currentSprite;
            MyNode *Tsprite = currentSprite;
            Bsprite.scale = 1.0;
            Tsprite.scale = 1.0;

            if(currentSprite.position.y >=253){
            Bsprite.position = ccp(currentSprite.position.x,-35);
                [self addChild:Bsprite];
                Bsprite.visible = TRUE;
            }
            if (currentSprite.position.y <=0) {
                Tsprite.position = ccp(currentSprite.position.x,324);
                [self addChild:Tsprite];
                Tsprite.visible = TRUE;
            }
            MyNode *isChanging;
            if ((Tsprite.visible == TRUE && currentSprite.visible == TRUE) || (Bsprite.visible == TRUE && currentSprite.visible == TRUE)) {
                isChanging = TRUE;
            }
            if (isChanging == FALSE) {
                [self removeChild:Tsprite cleanup:YES];
                [self removeChild:Bsprite cleanup:YES];
            }
        }
    }
  • 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-05-20T14:22:24+00:00Added an answer on May 20, 2026 at 2:22 pm

    It is not possible to do with one sprite. But you can have two sprites. In common situation when your sprite is sliding along the screen only one sprite will be visible. But when it reaches the border the second one will be visible too. When the second one will completely enter the screen – remove (or hide) the first one.

    The best way to implement this is to create a CCNode subclass that will contain first and second sprite and will swap them if required. In this way all your logic will be very simple. You will just work with one CCNode (subclass) and will not think about swaping sprites – it will be done automatically by your class

    EDIT

    @interface MyNode : CCNode
    {
        CCSprite *sprite1;
        CCSprite *sprite2;
        CCSprite *currentSprite;
        bool isChanging; //indicates that now two sprites are visible
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a sliding switch. On the left would be Off and
I'm looking for a sliding effect like this: http://www.piccante.co/sliding-doors/index.htm But it's for MooTools and
So this sliding animation works great when viewing on the page, but if i
I have a sliding drawer implemented. But the problem is this: I have a
I am using this sliding top panel using mootools (for orientation, the code is
I am creating some sliding panels (accordion) and I want to slide the background
I have a sliding div menu made with jQuery, but you have to click
I've quickly made up a sliding doors example but I'm incorporating it into my
Trying to make a sliding panel where you can click next and back to
I used sliding doors technique, explained here: http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html With only one exception, that I

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.