Hi, I tried to learn 'tex_coords' according this article (
https://blog.kivy.org/2014/02/using-tex_coords-in-kivy-for-fun-and-profit/), I have some try, but sadly, it does not work. here is my code. I want my background moving, but now two problems, one is the texture is the whole altas png, why? two is the
texture.wrap = 'repeat' does not work, why? Hope someone kind have time to help me. Thanks in advance.
from kivy.uix.widget import Widget
from kivy.uix.relativelayout import RelativeLayout
from kivy.lang import Builder
from kivy.atlas import Atlas
from kivy.graphics import Rectangle
from kivy.core.image import Image as CoreImage
from kivy.properties import StringProperty
from kivy.clock import Clock
Builder.load_string('''
<MyLayout>:
Background:
img:'atlas://img/background'
''')
class MyLayout(RelativeLayout):
pass
class Background(Widget):
img = StringProperty('')
def __init__(self, **kwargs):
super(Background, self).__init__(**kwargs)
with self.canvas:
self.rect = Rectangle()
tr = Clock.create_trigger(self.do_update_rect)
self.bind(img = tr,size = tr,pos = tr)
Clock.schedule_interval(self.update, 1 / 60.0)
def do_update_rect(self,*args):
texture = CoreImage(self.img).texture
texture.wrap = 'repeat'
self.rect.texture = texture
self.rect.pos = self.pos
self.rect.size = self.size
def update(self, *args):
t = Clock.get_boottime()
self.rect.tex_coords = t*0.01,1,1+t*0.01,1,1+t*0.01,0,t*0.01,0
# self.rect.tex_coords = 0,1,1,1,1,0,0,0
class MyApp(App):
def build(self):
return MyLayout()
if __name__ == '__main__':
MyApp().run()