S.J. Lim
S.J. Lim

Reputation: 3165

Is it possible resize a ccsprite in cocos2d without using scale property?

I'm trying to resize a ccsprite image.

My wanted resizing way is to decrease as pixel size without using scale property.

For example

    CCSprite *sprite1 = [CCSprite spriteWithFile:@"iphone_cellg4.png"];
    sprite1.position = CGPointMake(100, 0);
    sprite1.anchorPoint = CGPointZero;
    sprite1.(???).width -= 50; <= Decrease 50 pixel. Is correct this way?

How to resize a pixel size of ccsprite without using scale property?

Upvotes: 1

Views: 3086

Answers (1)

Ultrakorne
Ultrakorne

Reputation: 1303

so you want to use a subset of the texture? you can use

CCSprite *sprite1 = [CCSprite spriteWithFile:@"iphone_cellg4.png" rect:CGRectMake(x,y)];

to make a sprite with a different size. You can also modify the displayed texture of an existing sprite with

[sprite1 displayedFrame:[CCSpriteFrame frameWithTexture:texture rect:CGRectMake(x,y)]]

Upvotes: 1

Related Questions