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 / UI Design - boxes with rounded corners

Author
Message
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Jun 2014 11:11
Hi everyone. I've got a lot of UI elements that I've gone with blank textures and rectangular shapes because I can't really wrap my head around a good way to make text boxes with rounded corners.

Does anyone have a nice clean method for text boxes that have a border with rounded corners? I'd like have the edges scalable too so I can do something like use a tiled image.

Any ideas?
If not then looks like I'll be lazy and make images!

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Jun 2014 11:21
I'd use a memblock, unfortunately I can't really explain how I'd do it, but imagine a small version of your text box, say 64x64, I'd make a memblock image for the required size, then copy over the raw data from the 64x64 image to construct it.

It probably wouldn't be too slow, and I'd be happy to make an example, it's the sort of thing that always comes in handy at some point.

I am the one who knocks...
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Jun 2014 11:50 Edited at: 17th Jun 2014 11:54
i believe v2 have new commands
DrawBox
DrawEllipse
i would draw border on screen use GetImage(, SaveImage( once.
load image, set image as editbox background.

or direct in a vector painting tool, use a close path, set border size and maybe fill it.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 17th Jun 2014 12:32
I use 9 sprites for each ui frame, three rows of three.

The top left is a corner, the same image is used for all corners. The top middle(left middle, right middle and bottom middle) is a join to join two corners, you can manipulate the uv so it repeats its pattern or you can stretch it in one direction for a clean edge. The centre sprite needs to be seamless and the uv is setup so it tiles nicely when stretched, or in some skins I have it transparent, or empty.

This system means you can stretch to any size in real time and keep a consistent look with nice rounded corners. Let me know if you need more details on this system?

Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 17th Jun 2014 14:13
Hi

In my first game, I have tried a method to create a menu/UI with 9 images.

Here is the function I have created to do that :



I have attached a zip with 9 images for you, to test this function.

http://www.dracaena-studio.com

Attachments

Login to view attachments
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 17th Jun 2014 20:47
Thanks for the suggestions everyone.
@Van B & Markus - Both good ideas, but I'd like to be able to use tiled images for the borders.

@Blendman - cool I'll check that out as soon as I have a chance

@Matty H - I'm interested in seeing an example. Using UV is what I'm thinking about. I think I completely forgot that we can scale the UV... Then I'll still have 9 sprites, but the 4 edges can use a tiled image so that there's never any stretching.

Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 17th Jun 2014 21:01 Edited at: 17th Jun 2014 21:04
@Naphier : I have forgotten the min() function :



To use the first function :


http://www.dracaena-studio.com
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 17th Jun 2014 23:03
The 9 sprites version is what I plan to use in the future. I have used it for websites and I think it's very common solution. I have seen it used in quite a few RPGs.

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 18th Jun 2014 12:05
Hi Naphier,

I currently don't use the uv for the edges but I plan to implement it soon. At the moment I stretch them in one direction which means you are limited to how then look but they can be any size. Manipulating an edge pattern with uv coordinates will mean you can have more varied frames but you may need to snap them to the nearest size to get a seamless join.

Here is my Frame class, it is built on top of an Entity2 class, not sure this will be any use to you but here it is:



Some useful things to think about:

You may want to separate how the images are handled, I use a Skin class which holds all the images, my Frame class has a SetSkin() command which changes the look of the Frame.

You should think about defining different edges(borders), there is an outside border which is used when the Frame is placed inside another Frame, but there is also an inside border which is used when putting things inside that frame. Then you may want to have a 'hit' border for detecting touches etc, this may not always correspond with the other borders for various reasons.

You may want to have a DebugDraw() command which draws all the various borders in different colours, it helps when putting ui's together and things don't seem to be working like they should, it allows you to see exactly what is going on.

If you are using tier 2 you can try my ui system if you like? Let me know if you need any more help.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Jun 2014 15:20
What Matty H and Blendman say.

I didn't read the details, but you can essentially provide one image and split it up into 9 subimages. I use a textfile to describe how to cut the image up. Then, you can be more creative and don't have to be symmetrical.

For boxes that only scale one way you could/should use 3 images. The result is much neater.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Jun 2014 01:43
Just use images and scale the inner part of the box. That's what I did for my iOS interface.

easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 24th Jun 2014 13:09
Seems like the general consensus is using 9 images, but wouldn't Van B's original suggestion of using memblocks be better?

I spent a while getting an algorithm sorted out, but here you go, it's finished!

main.agc


API.agc



Audacia Games - Latest WIP - AUTOMAYTE 2.1, AppGameKit one click deploy to Android
"When you've finished 90% of your game, you only have 90% left"
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Jun 2014 15:25
Why use 9 images when you can use 1 (see attached example)?

Attachments

Login to view attachments
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 25th Jun 2014 04:33 Edited at: 25th Jun 2014 04:34
Why use 1 image when you can just use 0? [See my previous post]

It'd be easy enough to modify my example to use a real image, use antialiasing, speed it up (it's really really slow atm), or even use tiled images (for keeping an aspect ratio)


Audacia Games - Latest WIP - AUTOMAYTE 2.1, AppGameKit one click deploy to Android
"When you've finished 90% of your game, you only have 90% left"
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Jun 2014 10:27 Edited at: 25th Jun 2014 10:52
I wasn't saying your way was wrong or not good but I do think my way is easier to edit for your own uses. You could replace my 1 image with any sized corner image of any style easily and still get the same effect as the 9 image method.

Using no images has a clear memory advantage but in my book an easy to adapt and re-use method is normally more useful.

Here are a couple of examples using my method after about 15 minutes borrowing and editing some images from the net:


EDIT: Also you should bear in mind that although your method although saves on the download size it will have more of an impact on runtime memory.

Attachments

Login to view attachments
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 25th Jun 2014 13:09 Edited at: 25th Jun 2014 13:15
@baxslash : thank you a lot for your code and example. I agree with you, it's a very interesting method !

It's easy to create a "menu editor", to create some menu with your method and save the menu in a txt file (or in the code) to create all of sort of menu/ui.

Thank you a lot !

http://www.dracaena-studio.com
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 25th Jun 2014 18:17
Any time

Login to post a reply

Server time is: 2024-11-25 06:43:17
Your offset time is: 2024-11-25 06:43:17