Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe99006

Browse files
update trajectoryProgress implementation
1 parent 9207c7f commit fe99006

File tree

1 file changed

+8
-8
lines changed
  • Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter6_graphics

1 file changed

+8
-8
lines changed

‎Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter6_graphics/ParticlePhysics.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ fun ControlledExplosion() {
106106
modifier = Modifier.fillMaxWidth(),
107107
value = visibilityThresholdLow,
108108
onValueChange = {
109-
visibilityThresholdLow = it
109+
visibilityThresholdLow = it.coerceAtMost(visibilityThresholdHigh)
110110
},
111-
valueRange = 0f..visibilityThresholdHigh
111+
valueRange = 0f..1f
112112
)
113113

114114
Text("visibilityThresholdHigh: $visibilityThresholdHigh")
115115
Slider(
116116
modifier = Modifier.fillMaxWidth(),
117117
value = visibilityThresholdHigh,
118118
onValueChange = {
119-
visibilityThresholdHigh = it
119+
visibilityThresholdHigh = it.coerceAtLeast(visibilityThresholdLow)
120120
},
121-
valueRange = visibilityThresholdLow..1f
121+
valueRange = 0f..1f
122122
)
123123
Spacer(Modifier.height(16.dp))
124124
}
@@ -199,10 +199,10 @@ class ExplodingParticle(
199199
// Each 0.1f change in trajectoryProgress 0.5f total range
200200
// corresponds to 0.2f change of current time
201201
trajectoryProgress =
202-
if (explosionProgress < visibilityThresholdLow||
203-
(explosionProgress > visibilityThresholdHigh)
204-
) {
205-
return
202+
if (explosionProgress < visibilityThresholdLow) {
203+
0f
204+
} elseif (explosionProgress > visibilityThresholdHigh) {
205+
1f
206206
} else {
207207
explosionProgress
208208
.mapInRange(visibilityThresholdLow, visibilityThresholdHigh, 0f, 1f)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /