Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Start Screen Button Help

Author
Message
ChoppingLemons
11
Years of Service
User Offline
Joined: 25th Sep 2012
Location:
Posted: 27th Sep 2012 00:21
I want to know if there is anyway you could have an image that works like a button. If you could give some sample code with to help explain I would appreciate it very much. I am a noob when it comes to agk so if there was some article you found that helped you out when you first start a would also appreciate.
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 27th Sep 2012 01:26
AGK has built in button commands which automises most of the process.

Scroll down to "Universal - Button" and make special note of the SetVirtualButtomImageUp() and SetVirtualButtonImageDown() commands.

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Sep 2012 14:57
Or you could use the image as a sprite and check for a button press with the following:


GetPointerReleased() is one when, you guessed it, the mouse button, or screen touch is released.

GetSpriteHitTest() checks if the coordinates are within the bounds of a sprite.

I use this in my UI engine and it works very nicely.

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Sep 2012 15:07
The main advantage of the built in commands is that by pressing a "virtualButton" the pointer is disabled so you don't get a click registered when the user clicks on a button.

Using sprites is better when you want to define the shape of your button a little better. I tend to use my own pointer UDT so I can set the pointer state manually when one of my sprite buttons is pressed.


this.mess = abs(sin(times#))
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 28th Sep 2012 18:34
Quote: "The main advantage of the built in commands is that by pressing a "virtualButton" the pointer is disabled so you don't get a click registered when the user clicks on a button."

What do you mean exactly? What is advantage of having the pointer disabled? I cannot figure out an use case for that. Thanks in advance for the reply.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Sep 2012 18:37
Quote: "What do you mean exactly? What is advantage of having the pointer disabled? I cannot figure out an use case for that. Thanks in advance for the reply."

When the user clicks on a virtual button the command "getPointerPressed" returns zero.

The advantage is that if you don't want another action to happen that is caused by "getPointerState" or one of the other pointer commands (in your code) this won't happen using a virtual button.


this.mess = abs(sin(times#))
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Sep 2012 19:00
I was happy to see that my suggestion about a rectangular virtual button (issue #348) was accepted (and with medium priority). It will be nice when that is implemented.

I like virtual buttons. But it would be nice to have more than 12.

Cheers,
Ancient Lady
AGK Community Tester
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Sep 2012 19:02
Yes 12 is becoming a problem with my new Level Editor right now... I may be asking for an increase


this.mess = abs(sin(times#))
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 28th Sep 2012 19:55
Thank you! It would certainly help with my own level editor and some of my game functions.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-05-04 16:15:26
Your offset time is: 2024-05-04 16:15:26