Repository navigation
Add EmitTo for particles that travel to a target - #3
Merged
Merged
Conversation
Every effect so far throws particles and lets them go, which can say that something happened but not where it went. A reward landing on a score, an item going into a basket, is a flight with a destination and a moment of arrival. FlyingStarParticle follows a quadratic bezier from origin to destination, the control point lifted perpendicular to the flight so it lobs rather than sliding, spinning throughout, shrinking slightly on approach and fading over the final stretch so it dissolves into the target instead of stopping dead. It raises Arrived on the frame it lands, and EmitTo marshals that onto the main thread so the target can react there and then. ParticleBase gains IsFinished, and the animation loop removes particles that report it. Until now a particle was only removed by leaving the view, and one that flies to a target lands inside it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Emit(2.1.0) throws particles outward and lets physics take them. That says something happened, but not where it went. A reward landing on a score counter, an item going into a basket, is a flight with a destination and a moment of arrival.API
EmitTo(SKPoint from, SKPoint to, …)EmitTo(Point from, Point to, …)Optional
color,size,durationMillis,arcHeight(fraction of distance;0is a straight line).How it moves
FlyingStarParticlefollows a quadratic Bézier with the control point lifted perpendicular to the flight, so it lobs rather than slides. It spins throughout, shrinks ~30% on approach, and fades over the final 15% so it dissolves into the target instead of stopping dead.Arrivedfires on the landing frame;EmitTomarshals the callback to the main thread.One change worth reviewing
ParticleBasegainsIsFinished, and the animation loop now removes particles that report it:Until now a particle was only ever removed by leaving the view — and one that flies to a target lands inside it, so it would never be cleaned up. Existing particles return
falseand are unaffected.TransformationMatrixmoved fromprivate settoprotected setso a subclass can drive its own motion; the getter is unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_012fvKRoJiVhmmARSE8k7Vtf