Page 2 of 2

Re: [Help] How to move object to mouse clicked loaction

Posted: Fri Sep 07, 2012 2:02 pm
by Petunien
I modified your game. Now its possible to select, deselect and move the image using the mouse. :)
I hope you wanted that. :shock:

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. :megagrin:

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.

Re: [Help] How to move object to mouse clicked loaction

Posted: Fri Sep 07, 2012 2:23 pm
by pat.clarke
Edited

oops didn't see the post above :) ty so much!!!

Re: [Help] How to move object to mouse clicked loaction

Posted: Fri Sep 07, 2012 2:34 pm
by Petunien
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. :)

Re: [Help] How to move object to mouse clicked loaction

Posted: Fri Sep 07, 2012 4:04 pm
by pat.clarke
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

Posted: Fri Sep 07, 2012 4:14 pm
by Petunien
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. ^^