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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:09:40+00:00 2026-06-11T06:09:40+00:00

I am working on a game and I would like to add a proper

  • 0

I am working on a game and I would like to add a proper slicing feature in it.. so when a sprite sliced, 2 new sprites should be created.. please check here

At the moment, I am just reducing the size and duplicating the sprites.. Something like this.. Thanks in advance..

 - (BOOL) sliceSprite: (Sprite *) sprite withPath: (UIBezierPath *) slicePath


 {

            CGSize size = sprite.size;
            size.width /= 2; 
            size.height /=2;
            sprite.size = size;
            sprite.sliced = YES;

            Sprite *newSprite = [[Sprite alloc] initWithImage: sprite.image];

            newSprite.position = sprite.position;
            newSprite.size = size;
            newSprite.sliced = YES;
            newSprite.inView = YES;
            newSprite.xVelocity = SLICE_SPEEDUP * sprite.yVelocity;
            newSprite.yVelocity = SLICE_SPEEDUP * sprite.xVelocity;
            newSprite.angularVelocity = -SLICE_REVUP * sprite.angularVelocity;

            [sprites addObject: newSprite];
            [newSprite release];

        sprite.angularVelocity = SLICE_REVUP * sprite.angularVelocity;
            sprite.xVelocity = -SLICE_SPEEDUP * sprite.xVelocity;
            sprite.yVelocity = -SLICE_SPEEDUP * sprite.yVelocity;

            return YES;
    }

- (void) sliceSpritesInSwipePath
{
    CGRect swipeRect = [swipePath bounds];


        for (NSUInteger i = 0; i < [sprites count]; i++)
        {
                Sprite *sprite = [sprites objectAtIndex: i];

                if ([sprite intersectsWithPathInArray: swipePoints
                                               inRect: swipeRect])
                        if ([self sliceSprite: sprite withPath: swipePath])
                        {

                                [self resetSwipe];

                                if (![sliceSound isPlaying])
                                        [sliceSound play];

                break;
                        }
        }

}

  • 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-11T06:09:42+00:00Added an answer on June 11, 2026 at 6:09 am

    Since you’re using CoreGraphics here, why not simply use a clipping path when drawing the sprite(s)?

    Duplicate the sprite to be sliced, then apply simple polygons masking the two halves as their respective clipping paths. The function you need is called CGContextClip and a short tutorial can be found here.

    Edit: The tutorial lists this example:

    CGContextBeginPath (context);
    CGContextAddArc (context, w/2, h/2, ((w>h) ? h : w)/2, 0, 2*PI, 0);
    CGContextClosePath (context);
    CGContextClip (context);
    

    This sets the current path to a circle, then applies the current path as the clipping region.

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

Sidebar

Related Questions

I'm working on a game using OpenGL and C++. I would really like hardware
I am working on a game and would like to move the status bar(navigation
I'm working on a 3d game using OpenGL and would like to take it
So I am working on a game and I would like to make my
I am working on a game in Javascript, and I would like to be
For a game I am working on I would like to implement a scrolling
I'm working on a game engine in C++ and I have methods like setColour
I'm working on a game that uses local area network. Like most of multiplayer
I'm practicing writing MVC applications. I have a Mastermind game, that I would like
I'm working on creating an HTML5 game designed for six players and I would

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.