/////////////////////////////////////////////////////////////////////////// GameObject ///////////////////////////////////////////////////////////////////////////
| 387 | /// GameObject |
| 388 | //////////////////////////////////////////////////////////////////////////////// |
| 389 | bool 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 | |
| 443 | GameObjectPool::GameObjectPool(lua_State* pL) |
| 444 | : L(pL) |
no test coverage detected