ajout des coroutines qui re cache les taupes au bout d'un moment

probleme si on attend 20s
MenuNav
Pierre FERREIRA 2 years ago
parent 22d4249743
commit 23123ff054

@ -6,12 +6,12 @@
<type value="RUNNING_DEVICE_TARGET" /> <type value="RUNNING_DEVICE_TARGET" />
<deviceKey> <deviceKey>
<Key> <Key>
<type value="SERIAL_NUMBER" /> <type value="VIRTUAL_DEVICE_PATH" />
<value value="cb8d1519" /> <value value="/local/avd/Nexus_6_API_33.avd" />
</Key> </Key>
</deviceKey> </deviceKey>
</Target> </Target>
</runningDeviceTargetSelectedWithDropDown> </runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-04-07T15:38:03.714345Z" /> <timeTargetWasSelectedWithDropDown value="2023-04-07T16:42:24.439148Z" />
</component> </component>
</project> </project>

@ -1,4 +1,4 @@
#Fri Apr 07 17:44:06 CEST 2023 #Fri Apr 07 18:47:29 CEST 2023
base.0=/home/UCA/piferreira/2A/Android/testsansgradle/ProjetAndroid/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex base.0=/home/UCA/piferreira/2A/Android/testsansgradle/ProjetAndroid/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex
renamed.0=classes.dex renamed.0=classes.dex
path.0=classes.dex path.0=classes.dex

@ -160,6 +160,9 @@ class MoleGridActivity : AppCompatActivity() {
moleList[index].changeState() moleList[index].changeState()
moleList[index].onMoleStateChanged(moleList[index]) moleList[index].onMoleStateChanged(moleList[index])
Log.d("index", index.toString()) Log.d("index", index.toString())
//reset dans 3s
launchMoleDisappearCoroutine(moleList[index])
} }
// Attendre un court moment avant de mettre à jour une autre taupe // Attendre un court moment avant de mettre à jour une autre taupe
delay(1000) delay(1000)
@ -172,4 +175,17 @@ class MoleGridActivity : AppCompatActivity() {
return true return true
} }
private fun launchMoleDisappearCoroutine(mole: Mole) {
CoroutineScope(Dispatchers.Main).launch {
delay(5000L) // attendre 5 secondes
if (!mole.isDead()){
mole.changeState() // mettre la taupe morte
mole.onMoleStateChanged(mole) // notifier la vue
user.score -= 50
user.nbMiss += 1
scoreDisplay.text = user.score.toString()
}
}
}
} }

@ -1,4 +1,4 @@
package iut.android.pierrepierre.model.Class package iut.android.pierrepierre.model.Class
class User (var score: Int = 0){ class User (var score: Int = 0, var nbMiss : Int = 0){
} }
Loading…
Cancel
Save