use raylib multi touch sample for testing
This commit is contained in:
parent
ed58477dd9
commit
e1902300fc
1 changed files with 41 additions and 5 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
|
|
@ -14,21 +15,56 @@ namespace Raylib_cs.Android;
|
|||
ScreenOrientation = ScreenOrientation.Landscape,
|
||||
ClearTaskOnLaunch = true
|
||||
),
|
||||
IntentFilter(new[] { Intent.ActionMain }),
|
||||
IntentFilter(new[] { Intent.ActionMain, Intent.CategoryLauncher }),
|
||||
MetaData(NativeActivity.MetaDataLibName, Value = "raylib")
|
||||
]
|
||||
public class MainActivity : RaylibActivity
|
||||
{
|
||||
private const int MAX_TOUCH_POINTS = 10;
|
||||
|
||||
protected override void OnReady()
|
||||
{
|
||||
Raylib.InitWindow(0, 0, "android_window");
|
||||
Raylib.InitWindow(0, 0, "raylib [core] example - input multitouch");
|
||||
var touchPositions = new Vector2[MAX_TOUCH_POINTS];
|
||||
|
||||
while (!Raylib.WindowShouldClose())
|
||||
{
|
||||
int tCount = Raylib.GetTouchPointCount();
|
||||
if (tCount > MAX_TOUCH_POINTS)
|
||||
tCount = MAX_TOUCH_POINTS;
|
||||
for (int i = 0; i < tCount; ++i)
|
||||
touchPositions[i] = Raylib.GetTouchPosition(i);
|
||||
|
||||
Raylib.BeginDrawing();
|
||||
Raylib.ClearBackground(Color.WHITE);
|
||||
Raylib.DrawFPS(10, 10);
|
||||
Raylib.DrawText("Hello Raylib-cs.Android", 20, 100, 100, Color.BLACK);
|
||||
Raylib.ClearBackground(Color.RAYWHITE);
|
||||
|
||||
for (int i = 0; i < tCount; ++i)
|
||||
{
|
||||
if ((touchPositions[i].X > 0) && (touchPositions[i].Y > 0))
|
||||
{
|
||||
// for some reason this only works on release mode
|
||||
Raylib.DrawCircleV(touchPositions[i], 34, Color.ORANGE);
|
||||
Raylib.DrawText(
|
||||
i.ToString(),
|
||||
(int)touchPositions[i].X - 10,
|
||||
(int)touchPositions[i].Y - 70,
|
||||
40,
|
||||
Color.BLACK
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Raylib.DrawText(
|
||||
"touch the screen at multiple locations to get multiple balls",
|
||||
10,
|
||||
10,
|
||||
20,
|
||||
Color.DARKGRAY
|
||||
);
|
||||
|
||||
Raylib.EndDrawing();
|
||||
}
|
||||
|
||||
Raylib.CloseWindow();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue