我正在制作游戏,其中我想设置用户只能在3天内玩游戏.. 当他在一天内玩了3次然后会弹出一条消息,表示你达到了极限并无法发挥更多......
答案 0 :(得分:0)
private fun isNewDay(): Boolean {
val date = Date()
val today: Int = DateFormat.format("dd", date).toString().toInt()
val ret = lastCheck == 0 || today > lastCheck
lastCheck = today
sharedPreferenceHandler.setAlbumCreatedDate(lastCheck)
return ret
}
if(isNewDay()){
//do what you want
}