I donβt quite understand how to use the canvas correctly for animated images.
See the attached snippet where I load an animated icon into the image and do both: (1) add_widget Image (2) create a Rectangle canvas command with texture = texture image
Animated Image Rectangle Texture Not
I read the entire Kivy tutorial and read Image and Canvas, and I realized that Image is a good high-level class with all this image animation processing, and Canvas is a coarser black and white canvas.
So here is my question: what is the Kivy-proper architecture for processing animations on Canvas? I watched the animation, but it looks like an animation similar to a matrix, such as translation, scaling, rotation.
Here's what I am doing now: I have a game with a large map window, and then a bunch of UX games in auxiliary windows In UX game helper windows, I do all the kivy layouts, etc. And I mainly use images, and therefore my icons are pleasantly animated
However, on the game map I use canvas:
Drawing all my game objects using this paradigm:
r=Rectangle(texture=some_Image.texture) map.canvas.add(r)
When the world needs to be redrawn:
1) map.canvas.clear()
2) draw all the things in their new positions and state (to be faster, I just have to keep track of dirty objects and locations and just draw them, but to be honest, I get fantastic pictures even with this clear level of clarity in every draw)
This, of course, is much faster and easier than creating and destroying hundreds of widget classes - why does the map canvas take place - right?
But the problem is that my animation icons in the zip file are not animated
Q: I think the canvas is wrong? Should I add an image for each of my game objects instead? (And take advantage of support for all animated images?)
from kivy.uix.relativelayout import RelativeLayout from kivy.uix.image import Image from kivy.app import App from kivy.graphics import Rectangle class MainApp(App): def __init__(self, **kwargs): super().__init__(**kwargs) self.root = RelativeLayout()