์์ : )
https://github.com/eazuooz/WindowAPI/commit/d2c9e0ff36c548bbad02a2227d4a67b1f8ccc0dc#
object Copy Constructor · eazuooz/WindowAPI@d2c9e0f
Show file tree Showing 16 changed files with 127 additions and 16 deletions.
github.com
๊ธฐ์กด์ ๊ฐ์ฒด๋ฅผ ์ด์ฉํ์ฌ ํด๋น๊ฐ์ฒด๋ค์ ์์ฑ์ ๊ทธ๋๋ก ์ฌ์ฉํด์
์๋ก์ด ๊ฐ์ฒด๋ฅผ ๋ง๋ค๊ณ ์ถ์๋ ๊ฐ ์์ ๊ฒ์ด๋ค.
๋ค๋ง ๋ณต์ฌ์์ฑ์๋ฅผ ์ด์ฉํด์ ๊ฐ์ฒด๋ฅผ ๋ณต์ฌํด์ ๋๊ฒจ์ค ๊ฒฝ์ฐ
๋์ ํ ๋น๋ ์ฃผ์๊ฐ์ด ์๋ก์ด๊ฐ์ฒด์ ๊ทธ๋๋ก ๋ณต์ฌ๊ฐ๋์ด
delete ํ ๋๋ ๊ฐ๋ค์ ์ฌ์ฉํ ๋ ์ฌ๋ฌ๊ฐ์ง ๋ฌธ์ ์ ์ ์ผ๊ธฐ์ํจ๋ค.
๊ทธ๋์ ๊ฐ์ ๋ณต์ฌํ๋ ๊ฒ์ด ์๋ ๊ทธ ๊ฐ์ ๋ค์ด์๋ ๊ฐ๋ค์ ์ด์ฉํด
์๋ก์ด ๊ฐ์ฒด๋ฅผ ์์ฑํํ ๋ณต์ฌํด์ ๋๊ฒจ์ค์ผ ํ๋ค.
๋ณต์ฌ ์์ฑ์๋ฅผ ์ด์ฉํ ๊ฐ์ฒด ์์ฑ ํจ์
template <typename T>
static __forceinline T* Instantiate(T* gameObject, eColliderLayer type)
{
T* newObject = new T(*gameObject);
Scene* playScene = SceneManager::GetPlayScene();
playScene->AddObject(dynamic_cast<Object*>(newObject), type);
return newObject;
}
์์ฑ์์์ ๋ชจ๋ ์ปดํฌ๋ํธ๋ค์ ๋ค์ ์๋ก ํ ๋นํด์ ๋๊ฒจ์ฃผ์ด์ผ ํ๋ค.
Object::Object(Object& other)
: mComponents{ }
, mPos{ other.mPos }
, mScale{ other.mScale }
, mbDead(false)
{
mComponents.resize((UINT)eComponentType::End);
for (Component* component : other.mComponents)
{
if (nullptr == component)
continue;
Component* newComp = CreateComponent(component);
AddComponent(newComp);
}
}
๊ทธ๋ฆฌ๊ณ ๊ฐ component๋ค์ ํน์ฑ์ ๋ง๊ฒ ๊ฐ๊ฐ ๋ณต์ฌ์์ฑ์๊ฐ ๋์๊ฐ์ ์๊ฒ๋
๊ณ์ธต์ ์ผ๋ก ์ ๋ถ ๊ตฌํํด์ค์ผ ํ๋ค.
'๐ Development Study > ๐ป Win32API' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
UIManager, UIBase (0) | 2022.11.09 |
---|---|
Tile Map (0) | 2022.11.02 |
Rigidbody (0) | 2022.10.20 |
API Math (0) | 2022.10.20 |
Animator (1) | 2022.10.13 |
๋๊ธ