I'm trying to embed an animated avatar that was created using Spine in Xamarin.Forms.
The idea is as follows: I want to create a Xamarin.Forms UI (XAML) in a PCL, instantiate a Game class of the Monogame Framework (Microsoft.Xna.Framework.Game) and have that game instance render on the Xamarin.Forms View.
I have managed to get a Spine animation to run on Xamarin.Android so far.
In the Android project, I can request an "Android View" service type from the Monogame game class, like that:
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
var g = new Game1(); //inherits from Microsoft.Xna.Framework.Game
SetContentView((View)g.Services.GetService(typeof(View)));
g.Run();
}
Is there a generic view type I can request from the Game class as to take that view and have it render on a Xamarin.Forms page? (That way I could leave all animation-related code in the PCL and have it render in a cross-platform style.)
Or is there any other way I can integrate the animation in Xamarin.Forms? The animation should exist alongside other Xamarin.Forms controls like buttons or a menu.
You can make a custom renderer: https://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/ of View Type
Also take a look at: https://github.com/xamarin/xamarin-forms-samples/tree/master/Native2Forms and https://github.com/xamarin/xamarin-forms-samples/tree/master/Forms2Native
For cross platform animations / drawing there's a really nice NControl library: https://github.com/chrfalch/NControl