Page 1 of 2

Need help with Iphone game Controls..

PostPosted: Thu Nov 03, 2011 10:48 pm
by RippeR7420
So I have diagnosed my problem, but I just need some help to fix it :)
I'm gonna try to explain it the best I can. Here it goes..

So, I have it set up to move my player Left, Right, and Jump. I can get him to run Left/Right smoothly using MouseEnter/MouseLeave, But when I try to incorporate
the jump in, I cant get the jump animation AND the x+/x- to work at the same time. ( it's either one or the other)..:( My guess is that is has something to do with when you use the KeyDown event, is has a Repeat option.. As the MouseEnter/MouseButtonDown do not. is there someone out there who can help me?
Hope I explained it good enough.

Thanks! and +1 :)

Re: Need help with Iphone game Controls..

PostPosted: Thu Nov 03, 2011 11:03 pm
by SuperSonic
Could you post the code? :)

Re: Need help with Iphone game Controls..

PostPosted: Thu Nov 03, 2011 11:50 pm
by skydereign
Chances are you are running into the multitouch limitation gE has. gE only supports a single mouse (xmouse, ymouse). So if you are using mouse enter for the movement, and then you click jump, the xmouse and ymouse change to the new clicked position. One way I found to avoid this is to have mouse button down event for the jump button to destroy itself, and recreate it. This will remove the tracking of the second mouse click.

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 1:26 am
by Fojam
i have found ways to fight the whole multitouch limitation

here is my code for the left mouse button down
Code: Select all
if(gamePlaying==1)
{
    if(moveRight==1)
    {
        moveRight=0;
        moveLeft=1;
        ChangeAnimation("man", "man_run_left", NO_CHANGE);
    }
    else
    {
        moveLeft=1;
        ChangeAnimation("man", "man_run_left", NO_CHANGE);
    }
}
ChangeAnimation("button_left", "button_left_selected", NO_CHANGE);

mouse button left up
Code: Select all
moveLeft=0;
if(moveRight==0)
{
    ChangeAnimation("man", "man_stand", NO_CHANGE);
}
ChangeAnimation("button_left", "button_left", NO_CHANGE);

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 2:13 am
by Hblade
Perhaps:
Code: Select all
else
    {
        moveLeft=1;
        ChangeAnimation("man", "man_run_left", NO_CHANGE);
    }


:P You have Else, and it makes the same code cept for the animation

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 3:40 am
by skydereign
Fojam, that is using a supported form of multitouch. Therefore it does not bypass the problems we have with multitouch. Multiple mouse button down/up events are supported, the problem gE has is the single mouse variables. So, you can have several buttons, but for instance, you can't have two joysticks. But, with the DestroyActor, you can use a joystick and a single button, where without it you couldn't.

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 4:46 am
by RippeR7420
Thanks for the replies guys! :)

Hey Sky, How did you get it to work your way?

I tried this:


On the JUMP button: Add->MouseButtonDown->SciptEditor->

Code: Select all
switch(STATE)
{
    case 0:
    ChangeAnimation("Stik", "StikJumpRight", NO_CHANGE);
    StikCollision.yvelocity=-13;
    STATE=4;
    break;
 
    case 1:
    ChangeAnimation("Stik", "StikJumpLeft", NO_CHANGE);
    StikCollision.yvelocity=-13;
    STATE=5;
    break;
 
    case 2:
    ChangeAnimation("Stik", "StikJumpRight", NO_CHANGE);
    StikCollision.yvelocity=-13;
    STATE=4;
    break;
 
    case 3:
    ChangeAnimation("Stik", "StikJumpLeft", NO_CHANGE);
    StikCollision.yvelocity=-13;
    STATE=5;
    break;
 
    case 4:
    break;
 
    case 5:
    break;
 
    case 6:
    break;
 
    case 7:
    break;
 
    case 8:
    break;
 
    case 9:
    break;
 
    case 10:
    break;
 
    case 11:
    break;
 
    case 12:
    break;
 
    case 13:
    break;
}

DestroyActor("Event Actor");


Now, I know this isn't the way to do it. I just don't know how to "ReCreate" it haha :)

also, Will this STATE method not work?

Thanks again for the Help! I don't know what I would do without you guys haha! :D

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 5:36 am
by skydereign
Well, you have create the same actor in the same spot, so just add a CreateActor event, and make it appear at (0,0) setting the absolute position to false. And as long as STATE is a global variable, then it'll work.

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 3:51 pm
by RippeR7420
+1:)

so heres what I got now.

I have my Jump set up in draw actor to change my animation, but the yvelocity=-12; is throwing my gravity off balance.
I tried to put the yvelocity=-12; in the MouseDownEvent on my JumpButton, but my character wont jump haha.

here is my DrawActor Script:


case 12 and case 13 are what I set as jump for now..


Code: Select all
switch(STATE)
{
    case 0:
    ChangeAnimation("Stik", "StikStandRight", FORWARD);
    STATE=0;
    break;
 
    case 1:
    ChangeAnimation("Stik", "StikStandLeft", FORWARD);
    STATE=1;
    break;
 
    case 2:
    ChangeAnimation("Stik", "StikRunRight0001", NO_CHANGE);
    StikCollision.x+=4;
    STATE=2;
    break;
 
    case 3:
    ChangeAnimation("Stik", "StikRunLeft0001", NO_CHANGE);
    StikCollision.x-=4;
    STATE=3;
    break;
 
    case 4:
    if(yvelocity>0)
    {
        ChangeAnimation("Stik", "StikFallRight", NO_CHANGE);
        STATE=6;
    }
    break;
 
    case 5:
    if(yvelocity>0)
    {
        ChangeAnimation("Stik", "StikFallLeft", NO_CHANGE);
        STATE=7;
    }
    break;
 
    case 6:
    break;
 
    case 7:
    break;
 
    case 8:
    break;
 
    case 9:
    break;
 
    case 10:
    break;
 
    case 11:
    break;
 
    case 12:
    ChangeAnimation("Stik", "StikJumpRight", FORWARD);
    STATE=12;
    break;
 
    case 13:
    ChangeAnimation("Stik", "StikJumpLeft", FORWARD);
    STATE=13;
    break;
}

if(yvelocity>3)
{
    if(STATE%2==1)
    {
        ChangeAnimation("Stik", "StikFallLeft", NO_CHANGE);
        STATE=7;
    }
    else
    {
        ChangeAnimation("Stik", "StikFallRight", NO_CHANGE);
        STATE=6;
    }
}
yvelocity++;


and this is my MouseButtonDownEvent Script:

Code: Select all
if(STATE==2)
{
    STATE=12;
}

else

if(STATE==0)
{
    STATE=12;
}

else

if(STATE==3)
{
    STATE=13;
}

else

if(STATE==1)
{
    STATE=13;
}


I know this code is messy as all hell, but so far its the way I have to make multitouch work for me..
any advice would be amazing and very much appreciated! :) :) :)

Re: Need help with Iphone game Controls..

PostPosted: Fri Nov 04, 2011 11:34 pm
by RippeR7420
So does the forum uploader not work anymore or somethin?

Re: Need help with Iphone game Controls..

PostPosted: Sat Nov 05, 2011 5:18 am
by skydereign
The forum uploader works for some browsers... It should work with the latest firefox though. But, the problem you are having sounds like your setting the wrong yvelocity. The button down event belongs to your button. That means yvelocity is the button's yvelocity. If you want to change the player's you should use player.yvelocity. Though you would see the button move. Anyway, since you are using the state system, you can change your mouse button down event to have this code.
Code: Select all
switch(STATE)
{
    case 0:
    case 2:
    STATE=12;
    break;

    case 1:
    case 3:
    STATE=13;
    break;
}

Re: Need help with Iphone game Controls..

PostPosted: Sun Nov 20, 2011 8:11 pm
by peedalein
Hi!

Ripper, I have the same problem, so I am kind of using your thread. Hope, that is ok :)

My actor is supposed to move in 3 directions - left - right - jump. I'd like to use MouseEnter Events for left - right.
They work fine unless the player uses the jump button which is a Mouse Button Down Event. The actor moves right or left. Once the jump button is pressed the x movement of the player stops.

I tried following skydereign's advice to destroy the jump button but it did not work. The problem persists.
This is the code I use (it is not the best programming style I know :)).

Thanks for any help :)


Right Direction Button Mouse Enter (For left direction it is basically the same, therefore I don't post it)

Code: Select all
if(Pause==0)


{ChangeAnimation("Rightbutton", "rightbuttoninactive_neu_small", FORWARD);};
MouseEnter = 1;


if (Pause == 0) {MinisterMove = 1;};


Right Direction Button Mouse Leave

Code: Select all
if (Pause == 0) {ChangeAnimation("Rightbutton", "rightbuttoninactive_small", FORWARD);
                };

if (Pause == 0) {MinisterMove = 0;
    ChangeAnimation("Minister", "financeminister_standing_small", FORWARD);
 
    MouseEnter = 1;
 

MinisterStop = 0;
MinisterDirec = 0;};


Jump Button Mouse Button Down

Code: Select all
if (Pause == 0) {ChangeAnimation("Event Actor", "jumpbuttoninactive_neu_small", FORWARD);
                };


if (Pause == 0) {

if(jump==1)
{
Minister.yvelocity=-16;
jump=0;
}


MinisterJump = 1;
    switch(MinisterDirec)
    {
 
 
        case 0:
        ChangeAnimation("Event Actor", "financeminister_stand_jump_small", FORWARD);
        break;
 
        case 1: //If previous animation was charLeft.
        ChangeAnimation("Event Actor", "financeminister_r_jump_small", FORWARD);
        break;
 
        case 2:
        ChangeAnimation("Event Actor", "financeminister_l_jump_small", FORWARD);
 

break;
 
    };


DestroyActor("Event Actor");
CreateActor("Jumpbutton", "jumpbuttoninactive_small", "(none)", "(none)", 312, 292, true);

                };



Jump Button Mouse Button Up
Code: Select all
 
if (Pause == 0) {
 
    ChangeAnimation("Event Actor", "jumpbuttoninactive_small", FORWARD);
                };

Re: Need help with Iphone game Controls..

PostPosted: Sun Nov 20, 2011 10:56 pm
by RippeR7420
Alright i dont know if going to be able to explain very well, but you upload you .ged file
I will fix it for you how i fixed mine:) or when i get around my comp i will try to post the code
to help:)

Re: Need help with Iphone game Controls..

PostPosted: Mon Nov 21, 2011 12:23 pm
by peedalein
Hi Ripper,

this is the file. Feel free to fool around with it :)

Re: Need help with Iphone game Controls..

PostPosted: Mon Nov 21, 2011 12:43 pm
by Chai
Well...

Why do not separate button become 2 parts on the screen.
First, is the big area for run or walk to left and right for you mouse, but you need keep space for the jump button
Second, Jump button. not put over the first button.