#include "animatedtexture.h" #include "graphics.h" #include #include #include AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFrames, uchar *framesPixels, int *framesDelay) : Texture(), m_numFrames(numFrames) { m_size.setSize(width, height); m_framesTextureId.resize(numFrames); m_framesDelay.resize(numFrames); for(int i=0;i= m_numFrames) m_currentFrame = 0; m_textureId = m_framesTextureId[m_currentFrame]; AnimatedTexturePtr self = asAnimatedTexture(); // continue to animate only if something still referencing this texture if(self.use_count() > 1) g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]); }