I modified your game. Now its possible to select, deselect and move the image using the mouse.
I hope you wanted that.
For selecting, I needed a function to check if the mouse and the image collide.
You can get an explanation here: https://love2d.org/wiki/BoundingBox.lua
(In this case, a collision check for circles would be better, but leave that for later)
The code is fully commented, and yes, I know I have a bad english, so please don't complain.
Please ask if you have questions.
PS: Please don't forget, this code is only an example of how things work. You have to read the comments and try to understand the code, the syntax, the structure, the logic, etc, so you will be able to do it yourself later. I've partly made an error with writing all of the code for you. Please use it like it was made for.
[Help] How to move object to mouse clicked loaction
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: [Help] How to move object to mouse clicked loaction
- Attachments
-
- lalala.love
- (12.5 KiB) Downloaded 140 times
Last edited by Petunien on Fri Sep 07, 2012 2:40 pm, edited 2 times in total.
"Docendo discimus" - Lucius Annaeus Seneca
-
- Prole
- Posts: 6
- Joined: Fri Sep 07, 2012 4:52 am
Re: [Help] How to move object to mouse clicked loaction
Edited
oops didn't see the post above ty so much!!!
oops didn't see the post above ty so much!!!
Last edited by pat.clarke on Fri Sep 07, 2012 4:00 pm, edited 1 time in total.
Re: [Help] How to move object to mouse clicked loaction
Sorry if I'm wrong, but did you see my post above yours?
It seems to me you answered without changing to site 2 and looking what's written there.
It seems to me you answered without changing to site 2 and looking what's written there.
"Docendo discimus" - Lucius Annaeus Seneca
-
- Prole
- Posts: 6
- Joined: Fri Sep 07, 2012 4:52 am
Re: [Help] How to move object to mouse clicked loaction
Thank you so much this was every thing I needed. The comments help so much!
Re: [Help] How to move object to mouse clicked loaction
You're welcome!
As long as you remind my "PS" above, I'll be still here to help you with any questions.
Have fun exploring the coding world.
As long as you remind my "PS" above, I'll be still here to help you with any questions.
Have fun exploring the coding world.
"Docendo discimus" - Lucius Annaeus Seneca
Who is online
Users browsing this forum: No registered users and 5 guests