Merge branch 'patch1' of https://github.com/pktangyue/cocos2d-x into pktangyue-patch1

This commit is contained in:
James Chen 2013-07-11 16:18:59 +08:00
commit 285c2440b7
3 changed files with 54 additions and 15 deletions

View File

@ -688,20 +688,10 @@ void Scale9Sprite::updateCapInset()
}
else
{
if (_spriteFrameRotated)
{
insets = CCRectMake(_insetBottom,
_insetLeft,
_spriteRect.size.width-_insetRight-_insetLeft,
_spriteRect.size.height-_insetTop-_insetBottom);
}
else
{
insets = CCRectMake(_insetLeft,
_insetTop,
_spriteRect.size.width-_insetLeft-_insetRight,
_spriteRect.size.height-_insetTop-_insetBottom);
}
insets = CCRectMake(_insetLeft,
_insetTop,
_spriteRect.size.width-_insetLeft-_insetRight,
_spriteRect.size.height-_insetTop-_insetBottom);
}
this->setCapInsets(insets);
}

View File

@ -44,7 +44,8 @@ static std::function<Layer*()> createFunctions[] = {
CL(S9FrameNameSpriteSheetInsetsScaled),
CL(S9FrameNameSpriteSheetRotatedInsets),
CL(S9_TexturePacker),
CL(S9FrameNameSpriteSheetRotatedInsetsScaled)
CL(S9FrameNameSpriteSheetRotatedInsetsScaled),
CL(S9FrameNameSpriteSheetRotatedSetCapInsetLater)
};
static int sceneIdx=-1;
@ -601,3 +602,41 @@ std::string S9FrameNameSpriteSheetRotatedInsetsScaled::subtitle()
{
return "createWithSpriteFrameName(); default cap insets; rendered scaled 4.5 X width, 2.5 X height";
}
//
//// Scale9FrameNameSpriteSheetRotatedSetCapInsetLater
//
void S9FrameNameSpriteSheetRotatedSetCapInsetLater::onEnter()
{
S9SpriteTestDemo::onEnter();
Size winSize = Director::sharedDirector()->getWinSize();
float x = winSize.width / 2;
float y = 0 + (winSize.height / 2);
CCLog("Scale9FrameNameSpriteSheetRotatedSetCapInsetLater ...");
auto blocks_scaled_with_insets = Scale9Sprite::createWithSpriteFrameName("blocks9r.png");
CCLog("... created");
blocks_scaled_with_insets->setInsetLeft(32);
blocks_scaled_with_insets->setInsetRight(32);
blocks_scaled_with_insets->setPosition(Point(x, y));
CCLog("... setPosition");
this->addChild(blocks_scaled_with_insets);
CCLog("this->addChild");
CCLog("... Scale9FrameNameSpriteSheetRotatedSetCapInsetLater done.");
}
std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::title()
{
return "Scale9Sprite from sprite sheet (stored rotated), with setting CapInset later";
}
std::string S9FrameNameSpriteSheetRotatedSetCapInsetLater::subtitle()
{
return "createWithSpriteFrameName(); setInsetLeft(32); setInsetRight(32);";
}

View File

@ -178,3 +178,13 @@ public:
virtual std::string subtitle();
};
// S9FrameNameSpriteSheetRotatedInsetsScaled
class S9FrameNameSpriteSheetRotatedSetCapInsetLater : public S9SpriteTestDemo
{
public:
virtual void onEnter();
virtual std::string title();
virtual std::string subtitle();
};