I am drawing a background into kivy, after which wrap and place a clear picture on high of it. Every second I transfer the placement of the clear just a little bit.
from kivy.app import App from kivy.uix.widget import Widget from kivy.properties import ObjectProperty from kivy.uix.picture import Picture from kivy.clock import Clock class ScrollApp(App): def construct(self): self.bkg = Background() self.clock = Clock.schedule_interval(self.bkg.scroll_texture, 1) return self.bkg class Background(Widget): plx_2 = ObjectProperty(None) def __init__(self, **kwargs): tremendous().__init__(**kwargs) # set as texture self.plx_2 = Picture(supply=r"assetsplx-2.2.png").texture self.plx_2.wrap = 'repeat' self.plx_2.uvsize = (1,-1) def scroll_texture(self, time_passed): # replace uvpos x,y = self.plx_2.uvpos x = x - 0.05 % 1 # this magic quantity will change later self.plx_2.uvpos = (x, y) # redraw the picture texture = self.property('plx_2') texture.dispatch(self) if __name__=='__main__': ScrollApp().run()
#:kivy 1.11.1 <Background>: canvas.earlier than: Rectangle: dimension : self.dimension pos : self.pos supply: "assetsplx-1.png" Rectangle: dimension : self.dimension texture: self.plx_2
The code works, however I really feel very odd about the best way I am redrawing the feel with dispatching itself as an occasion. Is there a greater approach? Second, now if I have been so as to add a number of clear pictures on high, I must add plenty of code. Is there a a greater approach than simply including one other
Rectangle within the
.kv file, including one other
ObjectProperty within the
Background class and many others, and many others.?