Tutorial: Make your onscreen buttons!

Learn how to make certain types of games and use gameEditor.

Tutorial: Make your onscreen buttons!

Postby lcl » Mon Oct 18, 2010 1:16 pm

Hello! :D

I decided to make onscreen buttons tutorial 'cause I found very good way to do it.
This post will also include little example of how to use them. :D

First go to global code and type this:
Code: Select all
#define NOTHING 0
#define RIGHT 1
#define LEFT 2
#define UP 3
#define DOWN 4
#define ATTACK 5
//you can name those what ever you want, this is just example... :)


Then create actor called buttons or something.. :D
Make as many clones of it as you want. Then give the clones the animations that you want them to have.

Then goto player draw actor script and create two variables, jump and move. Make them as global, integer.
Then write in to players draw actor script:
Code: Select all
yvelocity += .5;

switch(move)
{
    case RIGHT:
    x += 5;
    ChangeAnimation("Event Actor", "WalkRight", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;

    case LEFT:
    x -= 5;
    ChangeAnimation("Event Actor", "Walkleft", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;

    case JUMP:
    if (jump == 1)
    {
        yvelocity = - 10;
        jump = 0;
    }
    break;
}


Player - collision any side of ground repeat: yes - script editor:
Code: Select all
//Put here the physical response
jump = 1;


And to buttons mouse button down:
Code: Select all
switch(cloneindex)
{
    case 0:
    move = LEFT;
    break;

    case 1:
    move = RIGHT;
    break;

    case 3:
    move = JUMP;
    break;

    //you can add any amount of moves here and then describe them in players draw actor code.
}


buttons mouse button up:
Code: Select all
move = NOTHING;

if (animindex == put here the animindex of moving left)
{
    changeanimation(... stopLeft);
}

if (animindex == put here the animindex of moving right)
{
    changeanimation(... stopRight);
}


Tell me what you think!
And if you don't understand something, ask! :D
Attachments
photo.png
onscreen.zip
Here's example file, don't mind the graphics, they are really bad... :P
(25.71 KiB) Downloaded 395 times
Last edited by lcl on Sat Oct 22, 2011 8:19 pm, edited 1 time in total.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby Hblade » Tue Oct 19, 2010 8:30 pm

Very helpfull, thanks! :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby lcl » Tue Oct 19, 2010 8:37 pm

:D Glad you like it. (I know, that's your own comment, but I like it so much. :lol:)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby Hblade » Tue Oct 19, 2010 9:06 pm

Yeah, I forgot all about the #define lol :P thanks for reminding me xD
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby SirAz » Thu Oct 21, 2010 9:59 am

Hmm. I'm using variables for iphone movement at the moment, but it doesn't always work so well. Using states as you have seems a much more effecient way of doing things. This was really helpful, thanks!
User avatar
SirAz
 
Posts: 23
Joined: Fri Oct 01, 2010 10:47 pm
Location: United Kingdom
Score: 2 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby lcl » Thu Oct 21, 2010 11:10 am

SirAz wrote:Hmm. I'm using variables for iphone movement at the moment, but it doesn't always work so well. Using states as you have seems a much more effecient way of doing things. This was really helpful, thanks!


That's nice to hear. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby Bee-Ant » Sat Oct 22, 2011 4:28 pm

lcl wrote:
Code: Select all
yvelocity += .5;
switch(move)
{
    ***case: RIGHT:***
    x += 5;
    ChangeAnimation("Event Actor", "WalkRight", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;
   
    case LEFT:
    x -= 5;
    ChangeAnimation("Event Actor", "***Walklefht***", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;

    //etc
}

Be careful...mistype on code will cause an error ;)
I guess here the correct code:
Code: Select all
yvelocity += .5;
switch(move)
{
    case RIGHT:
    x += 5;
    ChangeAnimation("Event Actor", "WalkRight", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;
   
    case LEFT:
    x -= 5;
    ChangeAnimation("Event Actor", "WalkLeft", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;

    //etc
}

:)
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby SuperSonic » Sat Oct 22, 2011 5:20 pm

Very nice tutorial lcl. +1 man :D
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Tutorial: Make your onscreen buttons!

Postby lcl » Sat Oct 22, 2011 8:18 pm

SuperSonic wrote:Very nice tutorial lcl. +1 man :D

Thanks! :)
Bee-Ant wrote:
lcl wrote:
Code: Select all
yvelocity += .5;
switch(move)
{
    ***case: RIGHT:***
    x += 5;
    ChangeAnimation("Event Actor", "WalkRight", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;
   
    case LEFT:
    x -= 5;
    ChangeAnimation("Event Actor", "***Walklefht***", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;

    //etc
}

Be careful...mistype on code will cause an error ;)
I guess here the correct code:
Code: Select all
yvelocity += .5;
switch(move)
{
    case RIGHT:
    x += 5;
    ChangeAnimation("Event Actor", "WalkRight", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;
   
    case LEFT:
    x -= 5;
    ChangeAnimation("Event Actor", "WalkLeft", NO_CHANGE); //Make sure to choose no_change instead of forward
    break;

    //etc
}

:)

Oh yeah, thanks for pointing those, have to correct them. :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest