Scale9Sprite* Scale9Sprite::create(const Rect& capInsets,
                                   const std::string& file)
{
    Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite();
    if ( pReturn && pReturn->initWithFile(capInsets, file) )
    {
        pReturn->autorelease();
        return pReturn;
    }
    CC_SAFE_DELETE(pReturn);
    return NULL;
}
示例#2
0
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)
{
    Scale9Sprite* ret = new (std::nothrow) Scale9Sprite();
    if (ret && ret->initWithSpriteFrameName(spriteFrameName, Rect::ZERO))
    {
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);

    log("Could not allocate Scale9Sprite()");
    return nullptr;
}
示例#3
0
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)
{
    Scale9Sprite* pReturn = new Scale9Sprite();
    if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) )
    {
        pReturn->autorelease();
        return pReturn;
    }
    CC_SAFE_DELETE(pReturn);

    log("Could not allocate Scale9Sprite()");
    return NULL;
    
}
 Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets) const
 {
     Scale9Sprite* pReturn = new (std::nothrow) Scale9Sprite();
     if ( pReturn && pReturn->init(_scale9Image,
                                   _spriteRect,
                                   _spriteFrameRotated,
                                   Vec2::ZERO,
                                   _originalSize,
                                   capInsets) )
     {
         pReturn->autorelease();
         return pReturn;
     }
     CC_SAFE_DELETE(pReturn);
     return NULL;
 }
示例#5
0
Scale9Sprite* Scale9Sprite::resizableSpriteWithCapInsets(const Rect& capInsets) const
{
    // FIXME: there are no test cases for this method
    Scale9Sprite* ret = new (std::nothrow) Scale9Sprite();
    if (ret && ret->init(const_cast<Scale9Sprite*>(this),
                         _rect,
                         _rectRotated,
                         Vec2::ZERO,
                         _originalContentSize,
                         capInsets) )
    {
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);
    return nullptr;
}