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 980e631

Browse files
add particle property functions
1 parent 5da357f commit 980e631

File tree

2 files changed

+184
-108
lines changed

2 files changed

+184
-108
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun ControlledExplosion() {
4242
mutableFloatStateOf(1f)
4343
}
4444

45-
val particleCount = 1
45+
val particleCount = 100
4646

4747
val density = LocalDensity.current
4848

@@ -69,14 +69,17 @@ fun ControlledExplosion() {
6969
// initialDisplacementY = 10.dp.toPx() * randomInRange(-1f, 1f)
7070
// }
7171

72+
val min = randomInRange(0f, visibilityThresholdLow)
73+
val max = randomInRange(min, visibilityThresholdHigh)
74+
7275
ExplodingParticle(
7376
color = Color(listOf(0xffea4335, 0xff4285f4, 0xfffbbc05, 0xff34a853).random()),
7477
startXPosition = sizePxHalf.toInt(),
7578
startYPosition = sizePxHalf.toInt(),
76-
maxHorizontalDisplacement = sizePxHalf,
77-
maxVerticalDisplacement = sizePxHalf,
78-
visibilityThresholdLow = visibilityThresholdLow,
79-
visibilityThresholdHigh = visibilityThresholdHigh,
79+
maxHorizontalDisplacement = sizePxHalf* randomInRange(-.9f, .9f),
80+
maxVerticalDisplacement = sizePxHalf* randomInRange(0.2f, 0.38f),
81+
visibilityThresholdLow = min,
82+
visibilityThresholdHigh = max,
8083
initialDisplacementX = initialDisplacementX,
8184
initialDisplacementY = initialDisplacementY
8285
)

0 commit comments

Comments
(0)

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