Jump to content

Help on Lua GUI's?


Denz
 Share

Recommended Posts

Hi,

I have not been able to find tutorials on making GUI's, UI's and HUD's. I want to create a very simple GUI on the main menu for my game which some text you click on starts the game, goes to the options menu, credits, or exits the game. Also, for when you hover over the text it goes to for instance, the colour red (but not entirely needed, but would be great!).

 

I hope someone can help me out here, it would make my day smile.pngsmile.png

 

EDIT:

 

This is what it should look like (just quickly done in paint):

 

fa02ed6225.jpg

Kind regards,

Denz (Ryan)

 

CEO & Founder of Denton Development

(http://www.dentondev.net/)

Link to comment
Share on other sites

Probably the easiest answer is to say buy Aggror's FlowGui and incorporate that.

 

I did do a small tutorial showing a text input box which has some of the basic hud pasting elements. It can be found here

 

If you are highlighting on mouse over then for each option create two textures, normal and highlighted, You know the top left corner and the size of each texture so in the PostRender stage use window:GetMousePosition() to find out the current mouse location. If the mouse maps within any of the three texture areas then for that texture choose the highlighted version.

content over form, game play over all.

Link to comment
Share on other sites

Thanks for your replies. I hardly even know LUA so I don't know where to begin with this. What I've done so far is drawn the text "Start, Options, Exit" onto the screen. If I could get help on where about to start this and some code to start from it'd be great.

 

Kind regards,

Denz (Ryan)

 

CEO & Founder of Denton Development

(http://www.dentondev.net/)

Link to comment
Share on other sites

Ive been playign with Aggrors FlowGUI a bit and here is something I threw together as an experiment. The great thing about the flowgui is that it is basically a map that a player would play. This allow me the easiest ability to make it my own with out a lot of coding which im unable to do very well.

 

Im still trying to figure out how to make the start button and the quit button work but once I do, Ill rebuild this to make it smaller as size is apparently extremely important.

https://www.youtube.com/watch?v=I2sBI40GEpA

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Link to comment
Share on other sites

Take a look at the following code:

 

--Retrieve mouse coordinates
local mousePos = App.window:GetMousePosition()

--Check if the mouse.x is higher then the x position of the start text AND lower then the x position of the text end x.
-- this also needs to be done for y axis
if mousePos.x > button1.x and mousePos.x < (button1.x + button1Width) then
   System:Print("the position of the mouse is within the button ")
end

 

This image represent the code above.

 

post-45-0-87347200-1420023110_thumb.jpg

 

Since you want to check if the mouse is inside the button boundry, we have to perform these steps every frame.

 

So the code needs to be placed either in UpdateWorld or in PostRender. For instance

function Script:PostRender(context)
   local mousePos = App.window:GetMousePosition()
   if mousePos.x > 460 and mousePos.x < (460 + 100) then
       System:Print("the position of the mouse is within the button ")
   end

   App.context:SetColor(255, 255, 255)
   App.context:SetBlendMode(Blend.Alpha)
   App.context:DrawText("Start", 460, 280)
   App.context:SetBlendMode(Blend.Solid)
end

  • Upvote 2
Link to comment
Share on other sites

I'll attempt to do this again later this week.

Don't forget I've created this GUI system for the C++ users.

 

http://www.leadwerks.com/werkspace/files/file/537-tjui-31/

 

I've actually optimised it a hell of a lot since this build so when I have a sec I'll update it.

I only have the indie edition.

 

Kind regards,

Denz (Ryan)

 

CEO & Founder of Denton Development

(http://www.dentondev.net/)

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...