Exemple #1
0
void PhotoLayer::changeOk(Ref* pSender, TouchEventType type)
{
    if (type == TOUCH_EVENT_ENDED){
        Sprite* sprite = this->mask();
        
        ImageView* face = ImageView::create();
        Texture2D* texture = sprite->getTexture();
        SpriteFrame* spriteFrame = SpriteFrame::createWithTexture(texture, Rect(0, 0, texture->getContentSize().width, texture->getContentSize().height));
        ((Sprite*)face->getVirtualRenderer())->setSpriteFrame(spriteFrame);
        ((Sprite*)face->getVirtualRenderer())->setFlippedY(true);
        
        MainLayer* layer = (MainLayer*)this->getParent()->getParent();
        layer->changeFace(face);

        Layer* parent = (Layer*)this->getParent();
        this->removeFromParentAndCleanup(true);
        parent->removeFromParentAndCleanup(true);
    }
}