我正在尝试制作自定义进度条。我想要做的是让“barMask.png”有它的X比例取决于数字的百分比。我试过这样做:
barBack = CCSprite::create( "barBack.png" );
this -> addChild( barBack );
barMask = CCSprite::create( "barMask.png" );
barMask -> setPosition( barBack -> getPosition( ) );
this -> addChild( barMask );
然后在更新方法上
// Scale the width of barMask depending on the percentage of the progress.
barMask -> setScaleX( CURRENT_AMOUNT / TOTAL_AMOUNT );
然而,精灵是这样缩放的:
Frame 1: [ |||||||||| ]
Frame 2: [ |||||||| ]
Frame 3: [ |||||| ]
它缩小到中间。我该怎么做才能让它向左/向右缩小?像这样:
Frame 1: [ |||||||||| ]
Frame 2: [ ||||||||| ]
Frame 3: [ |||||||| ]
Frame 4: [ ||||||| ]
我知道 CCProgressTimer,但我想使用纯粹的精灵作为进度条。