@vt7vt wrote:
Hello!
This is my main image prepared with puzzle masks on itI have 30 mask pieces separately .png*
This is one of the masks, for example:
![]()
i'm starting to cut from top-left corner to along the top, so first puzzle is ok
I need to cut all pieces from my main image, but I have no idea how to do it.
Here is my code:std::vector<Sprite*> sprites; //masks Sprite *textureSprite = Sprite::create("maldive3.png"); textureSprite->setAnchorPoint(Point(0, 1)); textureSprite->setBlendFunc({ GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA }); for (int i = 0; i < puzzleName.size(); i++) { Sprite *mask = Sprite::create(puzzleName.at(i)); Size cs = mask->getContentSize(); mask->setPosition(Point(cs.width / 2, cs.height / 2)); RenderTexture *rt = RenderTexture::create(cs.width, cs.height); textureSprite->setPosition(Vec2(i * -cs.width, cs.height)); rt->beginWithClear(0, 0, 0, 0); mask->visit(); textureSprite->visit(); Director::getInstance()->getRenderer()->render(); rt->end(); Sprite *rtSprite = Sprite::createWithTexture(rt->getSprite()->getTexture()); addChild(rtSprite); rtSprite->setFlippedY(true); sprites.push_back(rtSprite); rtSprite->setPosition(Point((i + 0.5) * cs.width, 200)); this->addChild(rtSprite) }
I think the problem is in setting position to textureSprite but I have no idea how to solve it
Here is result:
Posts: 2
Participants: 2