"If intersect, reset the loc of me"

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Noytal
Posts: 9
Joined: Sun Apr 10, 2016 6:10 pm

"If intersect, reset the loc of me"

Post by Noytal » Mon May 02, 2016 11:43 am

I am making a matchstick puzzle game which has several buttons with matchstick images that rotate and change image as they snap to a grid using "if intersect(me, grid line x) then set the loc of me to the loc of grid line x" and similar if's for changing image and dimensions of the buttons. What I need to do now is make it so "If intersect(selected matchstick, any other matchstick) then set the loc of me to the loc of me when grabbed". This is to prevent the matchsticks from stacking behind one another.

I tried using:

Code: Select all

local sPos

on mouseDown
   get the loc of me
   put the loc of me into sPos
   Grab me
end mouseDown

on mouseUp
   if intersect(button "Match U1", button "Match U2") then
set the loc of me to the loc of sPos
end if
But it returns "error in object expression", near "505,185". So I know it is returning a location when mouseDown'd but I don't know how to fix it.

I can provide more details if requested, thank you for your help :)

Noytal
Posts: 9
Joined: Sun Apr 10, 2016 6:10 pm

Re: "If intersect, reset the loc of me"

Post by Noytal » Mon May 02, 2016 11:48 am

*I worked it out, it's cool!

I changed the "on mouseUp" section to:

Code: Select all

on mouseUp
   if intersect(button "Match U1", button "Match U2") then
      set the loc of me to sPos
   end if
   

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: "If intersect, reset the loc of me"

Post by dunbarx » Mon May 02, 2016 3:05 pm

Right on.

What would LC do with the "loc" of a "loc"?

Craig Newman

Post Reply