from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.vector import Vector
from kivy.clock import Clock
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.graphics import *
from plyer import accelerometer
class LabBall(Widget):
def __init__(self, **kwargs):
super(LabBall, self).__init__(**kwargs)
self.velocity_x = NumericProperty(0)
self.velocity_y = NumericProperty(0)
self.velocity = ReferenceListProperty(self.velocity_x, self.velocity_y)
self.acc_x = NumericProperty(0)
self.acc_y = NumericProperty(0)
val = accelerometer.acceleration[:3]
if val == (None, None, None):
self.acc_x=0
self.acc_y=0
else :
self.acc_x= accelerometer.acceleration[0]
self.acc_y= accelerometer.acceleration[1]
self.acc =ReferenceListProperty(self.acc_x,self.acc_y)
def move(self):
self.velocity = Vector(self.acc)+Vector(self.velocity)
self.pos = Vector(*self.velocity) + self.pos
class LabGame(Widget):
ball = ObjectProperty(None)
def __init__(self, **kwargs):
super(LabGame, self).__init__(**kwargs)
self.murs_verts = [[[0, 0], [0, self.height]], [[self.width, 0], [self.width, self.height]]]
self.murs_horiz = [[[0, 0], [self.width, 0]], [[0, self.height], [self.width, self.height]]]
def serve_ball(self, vel=(0,0)):
self.ball.center = self.center
self.ball.velocity = vel
def update(self, dt,**kwargs):
super(LabGame, self).__init__(**kwargs)
self.ball.move()
class LabApp(App):
def build(self):
game = LabGame()
game.serve_ball()
Clock.schedule_interval(game.update, 1.0 / 60.0)
return game
if __name__ == '__main__':
LabApp().run()
If i chage the line : self.velocity = Vector(self.acc)+Vector(self.velocity) to self.velocity = Vector(*self.acc)+Vector(*self.velocity)
I have the message : Type Object argument after * must be a sequence, not kivy.properties.ReferenceListPropertiy
Sombody please can help us
Thanks a lot
--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/SKgru9RjVYk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.