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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:12:02+00:00 2026-05-23T20:12:02+00:00

I am trying to bend my sprite upto a certain angle but cant figure

  • 0

I am trying to bend my sprite upto a certain angle but cant figure out the right way to do it.. i tried to study process to skew a Sprite which existed in Cocos2d 1.00 version but i cant find it in the latest version 0.99.5
Please help me figure out How to skew a Sprite in cocos2d ??

  • 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-23T20:12:03+00:00Added an answer on May 23, 2026 at 8:12 pm

    How about this patch for CCNode.h and CCNode.m of version 0.99.5? This patch includes the difference for skew between version 0.99.5 and version 1.0.0.

    I’ve also uploaded the patch to gist https://gist.github.com/1082368

    diff --git a/cocos2d/CCNode.h b/cocos2d/CCNode.h
    index d6faaf5..64acdc5 100644
    --- a/cocos2d/CCNode.h
    +++ b/cocos2d/CCNode.h
    @@ -105,6 +107,9 @@ enum {
        // position of the node
        CGPoint position_;
        CGPoint positionInPixels_;
    +   
    +   // skew angles
    +   float skewX_, skewY_;
    
        // is visible
        BOOL visible_;
    @@ -174,6 +179,20 @@ enum {
      @since v0.8
      */
     @property (nonatomic,readwrite) float vertexZ;
    +
    +/** The X skew angle of the node in degrees.
    + This angle describes the shear distortion in the X direction.
    + Thus, it is the angle between the Y axis and the left edge of the shape
    + The default skewX angle is 0. Positive values distort the node in a CW direction.
    + */
    +@property(nonatomic,readwrite,assign) float skewX;
    +
    +/** The Y skew angle of the node in degrees.
    + This angle describes the shear distortion in the Y direction.
    + Thus, it is the angle between the X axis and the bottom edge of the shape
    + The default skewY angle is 0. Positive values distort the node in a CCW direction.
    + */
    +@property(nonatomic,readwrite,assign) float skewY;
     /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. */
     @property(nonatomic,readwrite,assign) float rotation;
     /** The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time. */
    diff --git a/cocos2d/CCNode.m b/cocos2d/CCNode.m
    index 5392905..569cb22 100644
    --- a/cocos2d/CCNode.m
    +++ b/cocos2d/CCNode.m
    @@ -73,12 +75,32 @@
     #pragma mark CCNode - Transform related properties
    
     @synthesize rotation = rotation_, scaleX = scaleX_, scaleY = scaleY_;
    +@synthesize skewX = skewX_, skewY = skewY_;
     @synthesize position = position_, positionInPixels = positionInPixels_;
     @synthesize anchorPoint = anchorPoint_, anchorPointInPixels = anchorPointInPixels_;
     @synthesize contentSize = contentSize_, contentSizeInPixels = contentSizeInPixels_;
     @synthesize isRelativeAnchorPoint = isRelativeAnchorPoint_;
    
     // getters synthesized, setters explicit
    +
    +-(void) setSkewX:(float)newSkewX
    +{
    +   skewX_ = newSkewX;
    +   isTransformDirty_ = isInverseDirty_ = YES;
    +#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
    +   isTransformGLDirty_ = YES;
    +#endif
    +}
    +
    +-(void) setSkewY:(float)newSkewY
    +{
    +   skewY_ = newSkewY;
    +   isTransformDirty_ = isInverseDirty_ = YES;
    +#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
    +   isTransformGLDirty_ = YES;
    +#endif
    +}
    +
     -(void) setRotation: (float)newRotation
     {
        rotation_ = newRotation;
    @@ -237,6 +259,7 @@
    
            isRunning_ = NO;
    
    +       skewX_ = skewY_ = 0.0f;
            rotation_ = 0.0f;
            scaleX_ = scaleY_ = 1.0f;
            positionInPixels_ = position_ = CGPointZero;
    @@ -615,6 +638,14 @@
        if (rotation_ != 0.0f )
            glRotatef( -rotation_, 0.0f, 0.0f, 1.0f );
    
    +   // skew
    +   if ( (skewX_ != 0.0f) || (skewY_ != 0.0f) ) {
    +       CGAffineTransform skewMatrix = CGAffineTransformMake( 1.0f, tanf(CC_DEGREES_TO_RADIANS(skewY_)), tanf(CC_DEGREES_TO_RADIANS(skewX_)), 1.0f, 0.0f, 0.0f );
    +       GLfloat glMatrix[16];
    +       CGAffineToGL(&skewMatrix, glMatrix);                                                             
    +       glMultMatrixf(glMatrix);
    +   }
    +   
        // scale
        if (scaleX_ != 1.0f || scaleY_ != 1.0f)
            glScalef( scaleX_, scaleY_, 1.0f );
    @@ -757,19 +788,26 @@
    
            if ( !isRelativeAnchorPoint_ && !CGPointEqualToPoint(anchorPointInPixels_, CGPointZero) )
                transform_ = CGAffineTransformTranslate(transform_, anchorPointInPixels_.x, anchorPointInPixels_.y);
    -       
    +
            if( ! CGPointEqualToPoint(positionInPixels_, CGPointZero) )
                transform_ = CGAffineTransformTranslate(transform_, positionInPixels_.x, positionInPixels_.y);
    
            if( rotation_ != 0 )
                transform_ = CGAffineTransformRotate(transform_, -CC_DEGREES_TO_RADIANS(rotation_));
    
    +       if( skewX_ != 0 || skewY_ != 0 ) {
    +           // create a skewed coordinate system
    +           CGAffineTransform skew = CGAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(skewY_)), tanf(CC_DEGREES_TO_RADIANS(skewX_)), 1.0f, 0.0f, 0.0f);
    +           // apply the skew to the transform
    +           transform_ = CGAffineTransformConcat(skew, transform_);
    +       }
    +       
            if( ! (scaleX_ == 1 && scaleY_ == 1) ) 
                transform_ = CGAffineTransformScale(transform_, scaleX_, scaleY_);
    
            if( ! CGPointEqualToPoint(anchorPointInPixels_, CGPointZero) )
                transform_ = CGAffineTransformTranslate(transform_, -anchorPointInPixels_.x, -anchorPointInPixels_.y);
    -       
    +               
            isTransformDirty_ = NO;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out how to do this. I have the style but I'd
trying to work out how to install zipArchive extension with MAMP, but not having
I'm trying to figure out why the following codes doesn't return the same result:
Trying to do this with a single query, but want to get a list
I'm trying to bend views and drupal to my will. So far I've produced
Trying to find some information on this but am unable to get any results
Trying to execute a Powershell cmdlet from a MVC 3 Controller using impersonation but
Trying to insert data in database from edittext in android but data is not
Trying to create an SSIS package to process a Datacube. Using SMS 2008, I've
I've been going over this in my head and trying out different approaches for

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.