Adam's Lair Forum

game development and casual madness
It is currently 2017/03/26, 11:23

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to hande UI stuff
PostPosted: 2017/01/24, 19:11 
Veteran Member
Veteran Member
User avatar

Joined: 2015/10/04, 15:48
Posts: 153
Location: Germany
Role: Hobbyist
Hello Party People!

In most of my games I used a rectangle as bounding box for some ui elements.
For a simple menu, I just "attach" a rectangle to my menu text and check, if the mouse intersects the rectangle...

You can also use this method basically to check if you hovered a gameobject with your mouse or not...
Maybe it's not the best solution, but hey... it works ^^

Another method is to use raycasting instead. The problem is here that you have to attach a rigidbody component to every gameobject that should be hoveable. This is not a big deal, but I'm not sure if this is so clever, because in the end you have many rigidbody and this would have an impact on the performance of the game.

I think both solutions are not quite good.
Maybe you wouldn't recognize this "performance impact"... but I'm talking about > 300(maybe more ?) gameobjects...

Do u know how this problem could be solved in a proper way?

Best regards
Cross

_________________
Twitter | GitHub | Join Duality on Discord | itch.io


Top
 Profile  
 
PostPosted: 2017/01/24, 19:42 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1933
Location: Germany
Role: Professional
Any reason not to give YAUI a try? I think Bishop already uses it and I see a lot of potential there. :)

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2017/01/24, 21:09 
Veteran Member
Veteran Member
User avatar

Joined: 2015/10/04, 15:48
Posts: 153
Location: Germany
Role: Hobbyist
Let me show you an example:



In the picture you can see different buildings (e.g. game objects). What I want to know is how you have to deal with so many gameobjects if you want to select one of them.

It doesn't matter if I'm using YAUI or my custom UI code, because I also would define a lot of controls... (one per go)

Do u know what I mean?

_________________
Twitter | GitHub | Join Duality on Discord | itch.io


Top
 Profile  
 
PostPosted: 2017/01/25, 13:51 
Forum Adept
Forum Adept
User avatar

Joined: 2015/03/15, 02:49
Posts: 351
Location: Out there
Role: Hobbyist
I'd say that using the rectangle approach is your best bet. 300 rectangles is nothing a computer, even an ancient one, can't handle.

Also, from my understanding, your controls would fire only when there would be a mouseover event, making this approach the best fit.

I don't think there's a better alternative to what you want.

_________________
Hello there! Nice to meet you!
I have github. Apologies in advance for bad coding practices.


Top
 Profile  
 
PostPosted: 2017/01/26, 19:40 
Veteran Member
Veteran Member
User avatar

Joined: 2015/10/04, 15:48
Posts: 153
Location: Germany
Role: Hobbyist
The rectangle approach is the easiest one I think.

It might have been worth considering to use some techniques like a quadtree or a simple grid in which the rectangles are stored...

_________________
Twitter | GitHub | Join Duality on Discord | itch.io


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group