i have developed cocos 2dx
game in which i am running animation
in the Sprite
in which i want to get the current texture name
for that i have tried following code:
CCSpriteFrame *frameN = fisherManBoat->displayFrame();
frameName = frameN->_textureFilename;
But it gives me error that textureFilename
is protected so how can i resolve it ? If it doesn't work then what else i can try? Because there is a button on the screen on which i tap and animation runs, i want to make it smooth. So, that if animation is in between on taping again it doesn't starts from again but from its current point.
if you want to access the _textureFilename variable the you need to modify the CCSpriteFrame.h file.
First you need to find this code in CCSpriteFrame.h file
protected:
Vec2 _offset;
Size _originalSize;
Rect _rectInPixels;
bool _rotated;
Rect _rect;
Vec2 _offsetInPixels;
Size _originalSizeInPixels;
Texture2D *_texture;
std::string _textureFilename;
PolygonInfo _polygonInfo;
And cut below line from this code
std::string _textureFilename;
now you have to paste it on top of CCSpriteFrame.h file where Public Scope is define.
class CC_DLL SpriteFrame : public Ref, public Clonable
{
public:
std::string _textureFilename;
I hope it will help you. Thanks.