To replace the current initialized skeleton in a SpinePlayer
while maintaining good performance on mobile, you can follow these steps:
Dispose of the Current Player: Use the
dispose()
method to clean up the currentSpinePlayer
instance. This will help manage resources effectively and prevent memory leaks.Reinitialize the Player: After disposing of the current player, create a new
SpinePlayer
instance with the new skeleton JSON and atlas files. This approach ensures that you are using a single WebGL context efficiently.Consider Using
spine-webgl
: If you need more control over rendering and performance, consider usingspine-webgl
directly. This runtime allows you to manage multiple skeletons within a single WebGL context, which can be more efficient than using multipleSpinePlayer
instances.Optimize for Mobile: Be mindful of the number of WebGL contexts and resources used, as mobile devices have limitations. Ensure that you are not exceeding these limits by managing your resources carefully.
By following these steps, you can switch between different skeletons using a single WebGL instance while maintaining good performance on mobile devices.