question for change my keydown to screen button

Game Editor comments and discussion.

question for change my keydown to screen button

Postby Orlando911 » Thu Dec 30, 2010 4:43 am

first question :
now I want to convert my kew down from my computer to screen button, everything doing great, except :
when I made my key down from my computer for example (( down key for my player )) make my player go down, and there is option (( repeat )) , if I still press my down key, my player still move down,

but when I made my screen button (( down )) there is no option for repeat, so I want to make my player still move down when I press my screen button down, so how can I do it ( because there is no option for repeat screen button ( mouse button down )


second question : in my computer button, when I press space, make my player shoot from left to right,
but when I press down with space, my shoot will be different direction witch is X:40 and y:18 this is easy , go to my shooplayer >control panel > key down> press down button in my computer> script editor > then write xvelocity=16; and yvelocity=8;

but how can I do the same function when in my screen button ???

thank you
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby skydereign » Thu Dec 30, 2010 4:59 am

What I do is have a mouse button down event that changes the button's state so it's active. Then a mouse button up event to stop it. In that button's draw event, I check if state==1, then put your code.

You can set another actor's x and yvelocity by using the actor's name.
Code: Select all
bullet.xvelocity=10;


This will only work if there is only one bullet actor though. I'm not entirely sure what you mean though, so I can't give a best case example.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: question for change my keydown to screen button

Postby Orlando911 » Thu Dec 30, 2010 5:19 am

thank you to much, I will try it tomorrow, because I dont have wireless to test my game in my Iphone, but its look is great.
but what about the second question, If your answer about the if state, about my second question, it is not clear for me, if this answer is another option of my first question, I will use the second option witch is shotplayer.xvelocity I will try it tomorrow and let you know

thank you again,
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby skydereign » Thu Dec 30, 2010 8:18 am

Well I don't really understand your setup for your second question. The method you are using for the shooplayer seems rather odd if it is a bullet actor. If you want the bullet actor to move in a given direction, you would normally use a create actor event, for the bullet. That would set the xvelocity and yvelocity of the bullet actor. This I think would remove the problem you are having, but I was thinking there might be a purpose for your use of the keydown event.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: question for change my keydown to screen button

Postby Orlando911 » Thu Dec 30, 2010 9:54 pm

the purpose that I use my keydown, that is in the beginning I want to build my game in my computer and test it in my computer, then when I finish everything, I will create screen button, because in the beginning I did not know about Geplayer,

I will do my best then re write here, because the problem in the velocity,
for example :
my player by default : xvelocity =3;
and the view = xvelocity =3;

now I have left button screen, witch is if you press it
mouse button down > player.xveocity=-3;
(now when you press the leftt button screen the player xvelocity will be -3 and his direction will change from right to left)
but the problem when you leave the button I want my player become like before you press, I want his xvelocity = 3;
actually I did that, I chose mouse button up>edit script : then I wrote player.xvelocity = 3;
but the problem when I test my game and press the left button screen my player go to right, but when I leave my button my player doesnt change his direction , so i dont know how can I solve this problem .
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby schnellboot » Thu Dec 30, 2010 10:07 pm

add new variable : left
player -> draw actor
if(left==0)
{
xvelocity=3;
}
if(left==1)
{
xvelocity=-3;
}

button -> mouse button down
left=1;

button -> mouse button up
left=0;

this should work ..
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: question for change my keydown to screen button

Postby Orlando911 » Fri Dec 31, 2010 3:53 am

I will try and let you know , thank you
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby Orlando911 » Fri Dec 31, 2010 3:59 am

it is work very well, thank you to much ,
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby Orlando911 » Fri Dec 31, 2010 4:28 am

I tried to add the same function in the Right screen button, when I did,

right button work , but left doesnt work ? so how can I add same function for the 4 buttons (right, left, up and down)
because when I write mouse up for each one, I think this problem for example,

if I dont press any button, that mean
right = 0, left=0 , up=0 and down=0, so in the if statement may doesnt work with this, but I think may I have to add mouse up, in one button

is this right, ?

or when I press the right button, that mean left button = mouse up, so this the problem, so that the left doesnt work because in the same time when I press left that mean,
I want my player =5; and the same time the right button because (mouse up) xvelocity = 3
so there are to statement in the same time, how can I solve it
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby Orlando911 » Fri Dec 31, 2010 4:40 am

I solved it ,

if(left==0 && right==0)
{
xvelocity=3;
}
if(left==1&& right==0)
{
xvelocity=-3;
}

if(right==0 && left==0)
{
xvelocity=3;
}
if(right==1&& left==0)
{
xvelocity=5;
}

thank you, I will add up and down button in the same way
Orlando911
 
Posts: 84
Joined: Tue Dec 07, 2010 8:18 am
Score: 1 Give a positive score

Re: question for change my keydown to screen button

Postby schnellboot » Fri Dec 31, 2010 9:24 am

you're welcome! :)
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron