[Help] How to move object to mouse clicked loaction

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

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

Post 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.
Attachments
lalala.love
(12.5 KiB) Downloaded 141 times
Last edited by Petunien on Fri Sep 07, 2012 2:40 pm, edited 2 times in total.
"Docendo discimus" - Lucius Annaeus Seneca
pat.clarke
Prole
Posts: 6
Joined: Fri Sep 07, 2012 4:52 am

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

Post by pat.clarke »

Edited

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.
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

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

Post 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. :)
"Docendo discimus" - Lucius Annaeus Seneca
pat.clarke
Prole
Posts: 6
Joined: Fri Sep 07, 2012 4:52 am

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

Post by pat.clarke »

Thank you so much this was every thing I needed. The comments help so much!
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

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

Post 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. ^^
"Docendo discimus" - Lucius Annaeus Seneca
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests