java大神看看,microbit手表,为什么到了60分钟后,不会+1小时
input.onButtonPressed(Button.A, function () {if (min < 59) {
min += 1
} else if (min == 60) {
min = 0
hours += 1
}
})
input.onButtonPressed(Button.B, function () {
if (hours < 23) {
hours += 1
} else if (hours == 24) {
hours += 0
}
})
input.onGesture(Gesture.Shake, function () {
if (min == 60) {
min = 0
hours += 1
} else {
if (hours == 24) {
min = 0
hours = 0
}
}
time = "" + hours + ":" + min
basic.showNumber(0)
})
let hours = 0
let min = 0
let time = ""
time = ""
min = 0
hours = 0
basic.forever(function () {
basic.pause(60000)
min += 1
if (min == 60) {
min = 0
hours += 1
} else {
if (hours == 24) {
min = 0
hours = 0
}
}
})
页:
[1]