You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Avalonia.Samples/CustomControls/SnowflakesControlSample/README.adoc
+40-15Lines changed: 40 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -273,7 +273,7 @@ Here is the final class: xref:ViewModels/SnowflakeGameViewModel.cs[]
273
273
274
274
=== Step 3: Add the SnowflakesControl
275
275
276
-
Now it's time to add the needed `Control` to render our game. Therefore, we add a new folder `Controls` and inside we add a new class `SnowflakesControl.cs`. This class must inherit `Control`. In addition, we want to implement the interface `ICustomHitTest` in order to control hit-testing on our own.
276
+
Now it's time to add the needed `Control` to render our game. Therefore, we add a new folder `Controls` and inside we add a new class `SnowflakesControl.cs`. This class must inherit `Control`.
277
277
278
278
The control needs some https://docs.avaloniaui.net/docs/guides/custom-controls/how-to-create-advanced-custom-controls[[AvaloniaProperties\]] to allow us to bind to it.
279
279
@@ -374,7 +374,7 @@ public override void Render(DrawingContext context)
374
374
// Request next frame as soon as possible, if the game is running. Remember to reset the stopwatch.
@@ -387,31 +387,56 @@ This is how a single render frame would look like:
387
387
.Result of a single render loop
388
388
image:_docs/single_render_frame.png[]
389
389
390
-
As we wanted to implement `ICustomHitTest`, we will add the needed interface members, which is just the following method here:
390
+
As we want to check if our pointer is over any `Snowflake`, we will override the `OnPointerEntered` and `OnPointerMoved` methods. From the `PointerEventArgs` we can read the pointer position and forward it to a method that tests for hits,
0 commit comments