Limit 2 players in a game
Posted: Thu May 23, 2013 3:19 am
hello, i have a 2 player game similar to snake and ladders. But my problem is i have a 2 player game, a girl and a boy. i wanted to trap the code like theres only 2 players .The flow goes this way, when the user clicks either of the two players given, for example player 1 choses the girl player and then player 2 again choses the same girl player, and then the play button appears. My problem is how to trap each 2 actors(girl and boy actors) to limit only two selection before the play button appears. My current code was if both players are empty(coz you have to input a name for each player) the play button wont appear unless both players 1 and 2 are ready. I really need help on this. heres the code for the "Choose player card"
global pTwoname,pOnename,soundPlay,tPath,tChannelName,tType,pPath,pChannelName,pType,clickButton
global sPath, sChannelName, sType,disablePlayer,charSelection
on openCard
playAppear
stopButton
play stop pPath
end openCard
on preOpenCard
enable button "Actor 1"
enable button "Actor 2"
put empty into fld "cNameone" --fld "cNameone"
put empty into fld "cNametwo"
show img "choose avatar"
show btn "Actor 1"
show btn "Actor 2"
hide group "p1"
playAppear
showPlayerReady
if pOnename is not empty then
show img "player1"
disable btn "Actor 1"
end if
if pTwoname is not empty then
show img "player2"
disable btn "Actor 2"
end if
end preOpenCard
on playAppear
if pOnename is not empty and pTwoname is not empty then
show btn "ply"
else
hide btn "ply"
end if
end playAppear
on stopPreviousSound
if (mobileSoundOnChannel("intro") is empty) or (mobileSoundOnChannel("intro") is "could not find channel") then
put (specialFolderPath("engine") & "/intro.aif") into tPath
put "intro" into tChannelName
put "now" into tType
mobilePlaySoundOnChannel tPath, tChannelName, tType
else
mobileStopPlayingOnChannel "intro"
end if
end stopPreviousSound
on stopButton
if (mobileSoundOnChannel("play") is empty) or (mobileSoundOnChannel("play") is "could not find channel") then
put (specialFolderPath("engine") & "/play.aif") into pPath
put "play" into pChannelName
put "now" into pType
mobilePlaySoundOnChannel pPath, pChannelName, pType
else
mobileStopPlayingOnChannel "play"
end if
end stopButton
global pTwoname,pOnename,soundPlay,tPath,tChannelName,tType,pPath,pChannelName,pType,clickButton
global sPath, sChannelName, sType,disablePlayer,charSelection
on openCard
playAppear
stopButton
play stop pPath
end openCard
on preOpenCard
enable button "Actor 1"
enable button "Actor 2"
put empty into fld "cNameone" --fld "cNameone"
put empty into fld "cNametwo"
show img "choose avatar"
show btn "Actor 1"
show btn "Actor 2"
hide group "p1"
playAppear
showPlayerReady
if pOnename is not empty then
show img "player1"
disable btn "Actor 1"
end if
if pTwoname is not empty then
show img "player2"
disable btn "Actor 2"
end if
end preOpenCard
on playAppear
if pOnename is not empty and pTwoname is not empty then
show btn "ply"
else
hide btn "ply"
end if
end playAppear
on stopPreviousSound
if (mobileSoundOnChannel("intro") is empty) or (mobileSoundOnChannel("intro") is "could not find channel") then
put (specialFolderPath("engine") & "/intro.aif") into tPath
put "intro" into tChannelName
put "now" into tType
mobilePlaySoundOnChannel tPath, tChannelName, tType
else
mobileStopPlayingOnChannel "intro"
end if
end stopPreviousSound
on stopButton
if (mobileSoundOnChannel("play") is empty) or (mobileSoundOnChannel("play") is "could not find channel") then
put (specialFolderPath("engine") & "/play.aif") into pPath
put "play" into pChannelName
put "now" into pType
mobilePlaySoundOnChannel pPath, pChannelName, pType
else
mobileStopPlayingOnChannel "play"
end if
end stopButton