MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / ChangeResource

Method ChangeResource

LuaSTGPlus/GameObjectPool.cpp:389–441  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// GameObject ///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

387/// GameObject
388////////////////////////////////////////////////////////////////////////////////
389bool GameObject::ChangeResource(const char* res_name)
390{
391 LASSERT(!res);
392
393 fcyRefPointer<ResSprite> tSprite = LRES.FindSprite(res_name);
394 if (tSprite)
395 {
396 res = tSprite;
397 res->AddRef();
398 a = tSprite->GetHalfSizeX() * LRES.GetGlobalImageScaleFactor();
399 b = tSprite->GetHalfSizeY() * LRES.GetGlobalImageScaleFactor();
400 rect = tSprite->IsRectangle();
401 UpdateCollisionCirclrRadius();
402 return true;
403 }
404
405 fcyRefPointer<ResAnimation> tAnimation = LRES.FindAnimation(res_name);
406 if (tAnimation)
407 {
408 res = tAnimation;
409 res->AddRef();
410 a = tAnimation->GetHalfSizeX() * LRES.GetGlobalImageScaleFactor();
411 b = tAnimation->GetHalfSizeY() * LRES.GetGlobalImageScaleFactor();
412 rect = tAnimation->IsRectangle();
413 UpdateCollisionCirclrRadius();
414 return true;
415 }
416
417 fcyRefPointer<ResParticle> tParticle = LRES.FindParticle(res_name);
418 if (tParticle)
419 {
420 res = tParticle;
421 if (!(ps = tParticle->AllocInstance()))
422 {
423 res = nullptr;
424 LERROR("�޷��������ӳأ��ڴ治��");
425 return false;
426 }
427 ps->SetInactive();
428 ps->SetCenter(fcyVec2((float)x, (float)y));
429 ps->SetRotation((float)rot);
430 ps->SetActive();
431
432 res->AddRef();
433 a = tParticle->GetHalfSizeX() * LRES.GetGlobalImageScaleFactor();
434 b = tParticle->GetHalfSizeY() * LRES.GetGlobalImageScaleFactor();
435 rect = tParticle->IsRectangle();
436 UpdateCollisionCirclrRadius();
437 return true;
438 }
439
440 return false;
441}
442
443GameObjectPool::GameObjectPool(lua_State* pL)
444 : L(pL)

Callers 1

SetAttrMethod · 0.80

Calls 12

FindSpriteMethod · 0.80
FindAnimationMethod · 0.80
FindParticleMethod · 0.80
AllocInstanceMethod · 0.80
SetInactiveMethod · 0.80
SetCenterMethod · 0.80
SetRotationMethod · 0.80
SetActiveMethod · 0.80
GetHalfSizeXMethod · 0.45
GetHalfSizeYMethod · 0.45
IsRectangleMethod · 0.45

Tested by

no test coverage detected