Disable keyboard

You must understand the Game Editor concepts, before post here.

Disable keyboard

Postby motorollin » Mon Aug 20, 2007 8:47 am

When my player dies it re-spawns using a fade-in effect. For some reason if any keys are pressed during this effect the game goes very strange. Is there any way to temporarily disable the keyboard so the game will ignore key down events, and then re-enable at the end of the fade-in script?
motorollin
 
Posts: 54
Joined: Sun Aug 12, 2007 8:05 am
Score: 1 Give a positive score

Postby motorollin » Mon Aug 20, 2007 2:37 pm

Anyone?
motorollin
 
Posts: 54
Joined: Sun Aug 12, 2007 8:05 am
Score: 1 Give a positive score

Postby jimmynewguy » Mon Aug 20, 2007 2:41 pm

just use event disable on keydown and keyup(if it changes any thing) when your player dies and if his transp == 0 event enable keyup+down is how i would try to do it :D
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Postby motorollin » Mon Aug 20, 2007 3:14 pm

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!
motorollin
 
Posts: 54
Joined: Sun Aug 12, 2007 8:05 am
Score: 1 Give a positive score

Postby motorollin » Mon Aug 20, 2007 3:28 pm

Right, sorted :D I added the commands to disable key up and key down events in to the create actor event for my player. That means that the actor does not respond to any key events unless I tell it to. Then I modified the player's playerfadein timer event as follows:

Code: Select all
if ( playertransparency > 0 )
{
    playertransparency -= 0.02;
    ChangeTransparency("player", playertransparency);
}
else
{
    DestroyTimer("playerfadein");
    EventEnable("player", EVENTKEYDOWN);
    EventEnable("player", EVENTKEYUP);
}


which allows key up and down events to be received only once the player is in full view again. Thanks for the pointer Jimmy, couldn't have done it without you :D
motorollin
 
Posts: 54
Joined: Sun Aug 12, 2007 8:05 am
Score: 1 Give a positive score

Postby jimmynewguy » Mon Aug 20, 2007 5:04 pm

i didnt know what codes you used so i couldnt be of more help (at first), but glad i ended helping out any way :D
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest