How to make a button that will still work after being moved
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to make a button that will still work after being moved
Hello! I am trying to make a core game and need a button that works with the camera plugin in: https://github.com/vrld/hump I want to know a way to make a button that can move and still works, Thanks!
Re: How to make a button that will still work after being moved
Assuming you want a button located in a place in the world:
Use the camera library to translate world coordinates to screen coordinates. Then tell your GUI library to place it in the returned coordinates.
Use the camera library to translate world coordinates to screen coordinates. Then tell your GUI library to place it in the returned coordinates.
Re: How to make a button that will still work after being moved
I'm new to love and if I could have a code sample it would help, thanks!
Re: How to make a button that will still work after being moved
Here's an example using cam11 for camera and Gspot for GUI. It places two buttons on the map, one in Wermin and one in Garrt. I found the positions with Gimp because they have to be defined in image pixels. For maps, you use map coordinates.
Map credits: https://opengameart.org/content/rpg-map
Map credits: https://opengameart.org/content/rpg-map
- Attachments
-
- example-button-on-map.love
- (467.48 KiB) Downloaded 89 times
Re: How to make a button that will still work after being moved
I'm also still a bit confused about this could you explain this a little simpler, I also dont wanna make buttons with libraries with the camera plugin I was using.
Re: How to make a button that will still work after being moved
Take a look at the docs for cam11: https://notabug.org/pgimeno/cam11, specifically the section titled "Definitions".
Pay special attention to the distinction between screen coordinates and world coordinates. Try to understand both concepts.
Don't keep reading until you have read and understood it.
----------------------------
If you want your buttons in a fixed position in your map, you need to convert the map coordinates to screen coordinates. I don't know hump.camera, so I can't help you with it.
Once you have the screen coordinates, you can draw your button and use the same coordinates to recognize the click position.
If you want better help, you will need to provide more details about what you want to do.
Pay special attention to the distinction between screen coordinates and world coordinates. Try to understand both concepts.
Don't keep reading until you have read and understood it.
----------------------------
If you want your buttons in a fixed position in your map, you need to convert the map coordinates to screen coordinates. I don't know hump.camera, so I can't help you with it.
Once you have the screen coordinates, you can draw your button and use the same coordinates to recognize the click position.
If you want better help, you will need to provide more details about what you want to do.
Re: How to make a button that will still work after being moved
Could I have an example how to make this without a library for the buttons?
Re: How to make a button that will still work after being moved
No. If you don't want to use a GUI library, I have to assume you know how to draw buttons and make them clickable. I told you how to find out where to place them, and I gave you an example of how to set the button's x and y coordinates. Now it's up to you to do the groundwork.
Re: How to make a button that will still work after being moved
There are already many sample & complete .love projects posted in the Games & Creations subforum. I recommend browsing through there for something related/interesting. Download it, rename the .love to .zip, extract, and look at the code. It's a great way to learn new things!
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Who is online
Users browsing this forum: Bing [Bot] and 9 guests