Good advice. I didn't know about those functions. Unfortunately this doesn't work. Might need a bit more detail.
On collision with the player, the enemy calls the die() function:
- Code: Select all
void die()
{
CreateTimer("view", "stop", 12);
CreateTimer("Life_count", "stop", 12);
DestroyActor("player");
lives-=1;
if ( lives < 0 )
{
GameOver();
return;
}
Life_count.textNumber -=1;
DestroyActor("Event Actor");
CreateTimer("view", "viewmove", 10);
}
The two ¨stop¨ timers stop the view and life counter from scrolling in case the player is destroyed before they Key Up event to stop scrolling is received (which caused the screen to scroll forever).
Assuming it's not game over, the life counter is decremented, the colliding enemy is destroyed, and the ¨viewmove¨ timer is created.
When the view receives the viewmove timer event it does this:
- Code: Select all
MoveTo("view", -160.000000, -120.000000, viewscrollspeed, "player", "");
if ( view.x == -160 & view.y == -120 )
{
DestroyTimer("viewmove");
playertransparency=1;
CreateActor("player", "playerup", "(none)", "(none)", 0, 0, true);
ChangeTransparency("player", 1.000000);
CreateTimer("player", "playerfadein", 50);
}
This moves the view back to the middle of the screen from wherever it is, creates a new player which is transparent, and then creates the timer ¨playerfadein¨.
When the player receives the timer event ¨playerfadein¨ it does this:
- Code: Select all
if ( playertransparency > 0 )
{
playertransparency -= 0.02;
ChangeTransparency("player", playertransparency);
}
else
{
DestroyTimer("playerfadein");
}
This makes the player fade back in to view.
All of this works great when testing in GE. The problem is when I compile for GP2X. On the GP2X if I allow the player to collide with an enemy but don't press any keys then it works ok. But if I collide with an enemy while holding down any direction, the player disappears and the view moves back to the center, but the player doesn't fade back in. Disabling the player's key up and down events didn't seem to make any difference.
I'm totally stumped!