Re: Code Bugs
Posted: Tue Dec 31, 2013 9:00 pm
Hi,
I'll look into that tomorrow.
Kind regards,
Mark
I'll look into that tomorrow.
Kind regards,
Mark
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
itay1023 hi,itay1023 wrote:The button doesn't return to it's first location (myLoc variable).
Code: Select all
on mouseDown
if _startTheGame is true then
put true into lMouseClicked
put mouseLoc() into myLoc -- store the initial position, first location in your words
else
put false into lMouseClicked
put empty into myLoc
end if
end mouseDown
on mouseMove pX, pY
if lMouseClicked then
set the loc of me to pX,pY
theButtonVar
end if
end mouseMove
on mouseUp
if lMouseClicked then
set the loc of me to myLoc -- return to the initial position which we've stored in the mouseDown handler
put false into lMouseClicked
put empty into myLoc
cancel tMessageID
end if
end mouseUp
Code: Select all
global _life
global _startTheGame
global _score
global blackVar
local LocVar
local lMouseClicked
local tMessageID
local lOriginalLoc
on mouseDown
put true into lMouseClicked
put the loc of me into lOriginalLoc
end mouseDownCode: Select all
on mouseMove
if lMouseClicked is true then
put the mouseLoc into myLoc
set the loc of me to myLoc
theButtonVar
end if
end mouseMove
Code: Select all
on mouseUp
put false into lMouseClicked
set the loc of me to lOriginalLoc
end mouseUpJust a note for future forum readers to clarify: this is a developer preference, not a LiveCode requirement. LiveCode doesn't care what you name your variables or handlers, use whatever makes sense to you. It has become customary among some of us to follow certain guidelines in naming conventions, but except for restrictions on some forbidden characters, the LiveCode engine doesn't care.Variables that start with "my" are for inside single handlers only.