zSprite.h
class zSprite : public Sprite {
public:
static zSprite* create(const std::string& filename);
bool isTouchTexture(Vec2 worldPoint);
};
zSprite.cpp
zSprite* zSprite::create(const std::string &filename)
{
auto sprite = new (std::nothrow) zSprite();
if (sprite && sprite->initWithFile(filename))
{
sprite->autorelease();
return sprite;
}
CC_SAFE_DELETE(sprite);
return nullptr;
}
bool zSprite::isTouchTexture(Vec2 worldPoint)
{
Vec2 position = convertToNodeSpace(worldPoint);
unsigned int x = position.x;
unsigned int y = getContentSize().height - position.y;
auto temp = Sprite::createWithSpriteFrame(getSpriteFrame());
temp->setAnchorPoint(Vec2(0, 0));
temp->setPosition(Vec2(0, 0));
auto render = RenderTexture::create(getContentSize().width,