안드엔진: 엔티티

안드엔진을 사용하는 게임의 구성요소는 모두 Entity로 이루어진다. 이름하여, 엔티티-컴포넌트 모델. 즉, Scene,
Sprite, Text, ParticleSystem, Rectangle, Mesh 등은 모두 Entity 클래스를 상속하는 하위 클래스들이다.
Entity 클래스는 위치, 크기, 회전, 기울임, 스케일, 색상, 충돌 테스트 등 다양한 메서드를 가지고 있으니 꼭 한번씩은 살펴보아야 할 것이다. 몇 가지 유용한 메서드들을 나열해보면 다음과 같다.

렌더링
setVisible(pBoolean), isVisible()
setChildrenVisible(pBoolean) , isChildrenVisible()
setCullingEnabled(pBoolean), isCullingEnabled()
setZIndex(pInt), getZIndex()
setIgnoreUpdate(pBoolean), isIgnoreUpdate()
setChildrenIgnoreUpdate(pBoolean), isChildrenIgnoreUpdate()
구조
attachChild(pEntity)
detachSelf()
getRootEntity()
setParent(pEntity), hasParent()
sortChildren()
색상
setColor(pRed, pGreen, pBlue), getColor()
위치
setPosition(pX, pY), setPosition(pEntity)
getX(), getY()
setAnchorCenter(pAnchorCenterX, pAnchorCenterY)
크기
setWidth(pWidth), setHeight(pHeight), setSize(pWidth, pHeight)
회전
getRotation(), setRotation(pRotation)
isRotated()
getRotationCenterX(), getRotationCenterY(), setRotationCenterX(pRotationCenterX), setRotationCenterY(pRotationCenterY)
스케일(scale), 기울임(skew)도 회전과 유사한 이름을 메서드가 있음.
충돌
collidesWith(pOtherEntity)
그리고,
setTag(pInt), getTag()
setUserData(pObject), getUserData()


레이어
엔티티 클래스의 가장 간단한 사용처는 레이어로 사용하는 것이다. 행여, 레이어가 뭔지 모른다면 포토샵 등의 그래픽 프로그램을 실행시켜 보기 바란다.
Entity layer = new Entity(); scene.attachChild(layer) ;

좌표계
안드엔진 GLES2-AnchorCenter에서 좌표계의 기준점, 즉 (0, 0)은 왼쪽 아래이다. 





댓글

이 블로그의 인기 게시물

자바 암호화 확장 (JCE) 관련 자바 1.8.0_151 이후 변경 사항

좌표 변환: 회전 이동

HTTP POST