MCPcopy Create free account
hub / github.com/defold/defold / PlayNodeFlipbookAnim

Function PlayNodeFlipbookAnim

engine/gui/src/gui.cpp:4234–4283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4232 }
4233
4234 Result PlayNodeFlipbookAnim(HScene scene, HNode node, dmhash_t anim, float offset, float playback_rate, AnimationComplete anim_complete_callback, void* callback_userdata1, void* callback_userdata2)
4235 {
4236 InternalNode* n = GetNode(scene, node);
4237 n->m_Node.m_FlipbookAnimPosition = 0.0f;
4238 n->m_Node.m_FlipbookAnimHash = 0x0;
4239
4240 if(anim == 0x0)
4241 {
4242 dmLogError("PlayNodeFlipbookAnim called with invalid anim name.");
4243 return RESULT_INVAL_ERROR;
4244 }
4245 if(n->m_Node.m_TextureType != NODE_TEXTURE_TYPE_TEXTURE_SET)
4246 {
4247 dmLogError("PlayNodeFlipbookAnim called with node not containing animation.");
4248 return RESULT_INVAL_ERROR;
4249 }
4250
4251 n->m_Node.m_FlipbookAnimHash = anim;
4252 FetchTextureSetAnimResult result = FetchTextureSetAnim(scene, n, anim);
4253 if(result != FETCH_ANIMATION_OK)
4254 {
4255 CancelAnimationComponent(scene, node, &n->m_Node.m_FlipbookAnimPosition);
4256 n->m_Node.m_FlipbookAnimHash = 0;
4257 n->m_Node.m_TextureSetAnimDesc.Init();
4258 if(result == FETCH_ANIMATION_NOT_FOUND)
4259 {
4260 dmLogWarning("The animation '%s' could not be found.", dmHashReverseSafe64(anim));
4261 }
4262 else
4263 {
4264 dmLogWarning("Error playing animation '%s' (result %d).", dmHashReverseSafe64(anim), (int32_t) result);
4265 }
4266 return RESULT_RESOURCE_NOT_FOUND;
4267 }
4268
4269 if(n->m_Node.m_TextureSetAnimDesc.m_State.m_Playback == PLAYBACK_NONE)
4270 {
4271 CancelAnimationComponent(scene, node, &n->m_Node.m_FlipbookAnimPosition);
4272 if (anim_complete_callback != 0x0)
4273 {
4274 anim_complete_callback(scene, node, true, callback_userdata1, callback_userdata2);
4275 }
4276 }
4277 else
4278 {
4279 AnimateTextureSetAnim(scene, node, offset, playback_rate, anim_complete_callback, callback_userdata1, callback_userdata2);
4280 }
4281 CalculateNodeSize(n);
4282 return RESULT_OK;
4283 }
4284
4285 Result PlayNodeFlipbookAnim(HScene scene, HNode node, const char* anim, float offset, float playback_rate, AnimationComplete anim_complete_callback, void* callback_userdata1, void* callback_userdata2)
4286 {

Callers 4

CloneNodeFunction · 0.70
LuaPlayFlipbookFunction · 0.70
TEST_FFunction · 0.50
SetNodeFunction · 0.50

Calls 7

FetchTextureSetAnimFunction · 0.85
CancelAnimationComponentFunction · 0.85
dmHashReverseSafe64Function · 0.85
AnimateTextureSetAnimFunction · 0.85
CalculateNodeSizeFunction · 0.85
GetNodeFunction · 0.70
InitMethod · 0.45

Tested by 1

TEST_FFunction · 0.40