I am using setScale on my main scene (which is a CCLayer subclass), and using the CCFollow action to center on the player's sprite. When I zoom out (set the scale to less than 1.0), the player sprite and game view shifts up and to the right. I've tried removing the CCFollow action and adding a new one after the zoom, but that doesn't help.
Problem with CCFollow and zooming
(4 posts) (3 voices)-
Posted 1 year ago #
-
Anyone? Well I went ahead and hacked CCFollow, no this isn't the right way...
-(void) step:(ccTime) dt { #define CLAMP(x,y,z) MIN(MAX(x,y),z) if(boundarySet) { // whole map fits inside a single screen, no need to modify the position - unless map boundaries are increased if(boundaryFullyCovered) return; CGPoint tempPos = ccpSub( halfScreenSize, followedNode_.position); [target setPosition:ccp(CLAMP(tempPos.x,leftBoundary,rightBoundary), CLAMP(tempPos.y,bottomBoundary,topBoundary))]; } else { CCNode *n = (CCNode*)target; float s = n.scale; CGPoint pt = ccpSub( halfScreenSize, followedNode_.position ); pt.x *= s; pt.y *= s; [target setPosition:pt]; } #undef CLAMP }Posted 1 year ago # -
How you zooming ? individual sprite or layer itself ?
Posted 1 year ago # -
Anyone find a fix for this? Running into the same issue. It seems like kagakuninja's solution will work, but probably not ideal?
Posted 1 year ago #
Reply
You must log in to post.