void OUMapItemRole::Render(float fStartX, float fStartY)
{
    hgeAnimation* cur = GetCurAnimation();
    if(cur == NULL) return;

    cur->Render(m_fWorldX - fStartX, m_fWorldY - fStartY);
}
void OUMapItemRole::Update(float fDelta)
{
    hgeAnimation* cur = GetCurAnimation();
    if(cur == NULL) return;
    if(!cur->IsPlaying()) cur->Play();

    cur->Update(fDelta);
}
void OUMapItemRole::SetState(OUMAPROLE_ACT_STATE state)
{
    if(state == m_emState) return;

    hgeAnimation* cur = GetCurAnimation();
    if(cur != NULL)
    {
        cur->Stop();
    }

    m_emState = state;
    cur = GetCurAnimation();
    if(!cur)
    {
        this->m_fWidth = this->m_fHeight = 0;
    }

    cur->Play();
    m_fWidth = cur->GetWidth();
    m_fHeight = cur->GetHeight();
}
void OUMapItemRole::SetFaceDir(OUMAPROLE_FACE_DIR dir)
{
    if(dir == m_emFaceDir) return;

    hgeAnimation* cur = GetCurAnimation();
    if(cur != NULL)
    {
        cur->Stop();
    }

    m_emFaceDir = dir;
    cur = GetCurAnimation();
    if(!cur)
    {
        this->m_fWidth = this->m_fHeight = 0;
    }

    cur->Play();
    m_fWidth = cur->GetWidth();
    m_fHeight = cur->GetHeight();
}
bool OUMapItemRole::IsInsideScreen(float fStartX, float fStartY, float fScreenWidth, float fScreenHeight)
{
    hgeAnimation* cur = GetCurAnimation();
    if(cur == NULL) return false;

    float hx, hy;
    cur->GetHotSpot(&hx, &hy);

    hgeRect rect1(fStartX, fStartY, fStartX + fScreenWidth, fStartY + fScreenHeight);
    hgeRect rect2(m_fWorldX - hx, m_fWorldY - hy, m_fWorldX + m_fWidth - hx, m_fWorldY + m_fHeight - hy);

    return rect1.Intersect(&rect2);
}
Beispiel #6
0
//////////////////////////////////////////////////////////////////////////////////
/// Sets the actor to the correct walking animation as she/he walks a path.
void Actor::UpdateActorWalkingAnimation(long xPos, long yPos) {
	SetAutoAnimate(true);
	FindDirection(xPos, yPos);
	if(direction.x == 1 && direction.y == 0 && GetCurAnimation() != WALKING_RIGHT) {
		SetAnimation(WALKING_RIGHT);
	} else if(direction.x == 1 && direction.y == -1 && GetCurAnimation() != WALKING_RIGHT) {
		SetAnimation(WALKING_RIGHT);
	} else if(direction.x == 0 && direction.y == -1 && GetCurAnimation() != WALKING_FRONT) {
		SetAnimation(WALKING_FRONT);
	} else if(direction.x == -1 && direction.y == -1 && GetCurAnimation() != WALKING_LEFT) {
		SetAnimation(WALKING_LEFT);
	} else if(direction.x == -1 && direction.y == 0 && GetCurAnimation() != WALKING_LEFT) {
		SetAnimation(WALKING_LEFT);
	} else if(direction.x == -1 && direction.y == 1 && GetCurAnimation() != WALKING_LEFT) {
		SetAnimation(WALKING_LEFT);
	} else if(direction.x == 0 && direction.y == 1 && GetCurAnimation() != WALKING_BACK) {
		SetAnimation(WALKING_BACK);
	} else if(direction.x == 1 && direction.y == 1 && GetCurAnimation() != WALKING_RIGHT) {
		SetAnimation(WALKING_RIGHT);
	}
}