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 / Using rectangular button images

Author
Message
Seed
11
Years of Service
User Offline
Joined: 23rd Feb 2013
Location:
Posted: 29th May 2013 18:42 Edited at: 29th May 2013 18:44
Just wondering if there is a way around the square limitation for the buttons?. When changing the button images to a rectangle image e.g. http://www.edgecomputer.us/entrepreneuruniversity/images/yellow-rectangle-button-hi.png

The button area is still calculated in a square. So, a button press is activated in the equivalent height of the width of the image, which obviously is wrong.

Any solution to this?, or should I just make my own buttons for the rectangles?.
An easy temporary solution would be if I could get the x and y pos of the buttons and calculate my own button press, but I can't see a way of getting the x and y pos.
Thanks.

AGK tier 2 v811. iOS Xcode 4.6.2.
Using percentage system for coords, not setting virtual res.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th May 2013 18:52
There was a request that was accepted to allow rectangular virtual buttons. But it hasn't been done yet.

I stopped using virtual buttons a while ago because of that and make all my own buttons now. I created a nice set of classes to make my own buttons with text and they use GetSpriteHit to check for presses. (Not quite willing to share the code now, it is too integrated with other bits to simply extract just the buttons part.)

BTW, you should probably upgrad to v10812. It has some important bug fixes.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Seed
11
Years of Service
User Offline
Joined: 23rd Feb 2013
Location:
Posted: 29th May 2013 18:57
Ah fair enough. No need to worry about sharing your code. Will be easy enough to make it myself, was just hoping there was a method of setting rectangle buttons so that I wouldn't need to make it my self.
Also, I will get upgrading now.
Thanks.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th May 2013 19:22
Using Tier 2 gives us a lot more options and flexibility. I am very glad I converted my WIP. It would never be as complete and good as it is now if I had stayed with Tier 1.

Good luck and Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th May 2013 01:09
The inbuilt buttons are useful for prototyping, but as AL has done, I have made my own very nice buttons which size and stretch and can have many different looks / properties etc.

I also think there was some issue with their depth or something (might have been fixed or I am dreaming)

easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 30th May 2013 10:13 Edited at: 30th May 2013 10:15
Here's my code that I use for GUI buttons, it's quite modular which makes it easier to reuse:

With modification, it can be made multi-touch which makes it useful for other GUI things (shoot/fire button for instance)


Hope this helps a bit.

edit: you can use FixSpriteToScreen(id) if you move the Viewport in-game. if you DON'T use FixSpriteToScreen() and more the viewport (not sure why you'd do this though) whenever GetPointerX/Y() is called, you need to call it as ScreenToWorldX/Y(GetPointerX/Y())

AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 30th May 2013 18:40 Edited at: 30th May 2013 23:12
MissJoJo,

I took your functions and expanded them a bit (and also corrected the bugs).

Here's the new set of of expanded MissJoJo MakeButton functions, V1.00, Build 0004.



The attached ZIP contains the source and media files. Screenshot to follow.

@Seed:
These are fairly simple to convert to TIER 2, so I'll leave that as an exercise for readers.

Cheers,
AgentSam

Attachments

Login to view attachments
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 30th May 2013 18:41 Edited at: 30th May 2013 18:42
Here's the screenshot.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-25 13:58:10
Your offset time is: 2024-04-25 13:58:10