Button Question
Posted: Mon May 23, 2011 10:07 am
Hello, how Do I create a button that changes the look when i click on it (like button_normal and button_pressed) and after release the button it changes to a third stage?
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
on mouseup
play (specialfolderpath("engine") &"/click.aif")
## Do your other mouseup stuff...
## ...
end mouseup
Code: Select all
command playClick
play (specialfolderpath("engine") &"/click.aif")
end playClick
Code: Select all
on mouseup
playplayClick
## Do your other mouseup stuff...
## ...
end mouseup
Code: Select all
on mousedown
play (specialfolderpath("engine") &"/nice_loopable_sound.aif") looping
end mousedown
on mouseup
play empty
end mouseup
## Important!
on mouserelease
play empty
end mouserelase
I strongly doubt!cu3e wrote:Last question
Code: Select all
local sGameRunning, sTimer, sScore, sLevel, sDragging
on mouseDown
if sGameRunning is true then
put true into sDragging
end if
end mouseDown
on touchMove pId, pX, pY
if the cType of the target is "sheep" and sDragging is true then
set the loc of the target to pX, pY
end if
end touchMove
on touchEnd pId
put false into sDragging
if within(field "pen", the loc of the target) and the cType of the target is "sheep" then
delete the target
scoreIncrement
if the number of controls in group "sheep" < 1 then
add 1 to sLevel
levelGenerate
end if
end if
end touchEnd
on gameInitialize
lock screen
put 0 into sScore
put "x" && sScore into field "score"
put 30 into sTimer
put sTimer into field "time"
put 1 into sLevel
levelClear
levelGenerate
unlock screen
end gameInitialize
on levelGenerate
lock screen
reset the templateButton
set the style of the templatebutton to "transparent"
set the borderwidth of the templatebutton to "0"
set the showname of the templatebutton to "false"
set the width of the templatebutton to "60"
set the height of the templatebutton to "50"
set the icon of the templatebutton to "5002"
set the visible of the templatebutton to true
set the autohilite of the templatebutton to false
set the cType of the templateButton to "sheep"
set the sharedhilite of the templateButton to false
set the traversalon of the templateButton to false
set the threed of the templateButton to false
set the hiliteborder of the templateButton to false
repeat with x = 1 to sLevel
levelAddSheep x
end repeat
unlock screen
end levelGenerate
on levelClear
lock screen
repeat with x = the number of controls in group "sheep" down to 1
delete control x of group "sheep"
end repeat
unlock screen
end levelClear
on levelAddSheep pNumber
repeat forever
put random(300 - 20 + 1) + 20 - 1, random(400 - 20 + 1) + 20 - 1 into tLoc
if tLoc is not within the rect of control "pen" then
exit repeat
end if
end repeat
set the loc of the templateButton to tLoc
create button ("sheep"&pNumber) in group "sheep"
end levelAddSheep
on scoreIncrement
add 1 to sScore
put "x" && sScore into field "score"
end scoreIncrement
on gameStart
put true into sGameRunning
set the icon of button "start" to 5001
send "timerPlay" to me in 1 second
end gameStart
on gameStop
put false into sGameRunning
set the icon of button "start" to 5000
gameInitialize
end gameStop
on timerPlay
if sGameRunning is true then
subtract 1 from sTimer
if sTimer > 0 then
put sTimer into field "time"
send "timerPlay" to me in 1 second
else
put false into sGameRunning
put sScore into field "finalscore" of group "result"
show group "result"
set the layer of group "result" to top
end if
end if
end timerPlay
on motionStart pMotion
if pMotion is "shake" then
gameStop
set the layer of group "result" to 1
hide group "result"
end if
end motionStart