mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Kivy/Android
- reworked positioning during animations
This commit is contained in:
parent
ce0e6ff856
commit
288bd920af
3 changed files with 42 additions and 26 deletions
|
@ -1455,7 +1455,7 @@ class Game(object):
|
||||||
c0 = cards[0]
|
c0 = cards[0]
|
||||||
dx, dy = (x - c0.x), (y - c0.y)
|
dx, dy = (x - c0.x), (y - c0.y)
|
||||||
base = float(self.app.opt.animations)
|
base = float(self.app.opt.animations)
|
||||||
duration = base*base/20.0 + 0.05
|
duration = base*base/25.0 + 0.05
|
||||||
for card in cards:
|
for card in cards:
|
||||||
card.animatedMove(dx, dy, duration)
|
card.animatedMove(dx, dy, duration)
|
||||||
# self.top.waitAnimation(swallow=True, pickup=True)
|
# self.top.waitAnimation(swallow=True, pickup=True)
|
||||||
|
|
|
@ -120,7 +120,7 @@ class LAnimationTask(LTask, LBase):
|
||||||
self.anim = anim
|
self.anim = anim
|
||||||
self.spos = spos
|
self.spos = spos
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
# print(self.widget.card)
|
print(self.widget.card)
|
||||||
self.delay = delay
|
self.delay = delay
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
|
@ -279,6 +279,7 @@ class MfxCanvasImage(object):
|
||||||
# animation support:
|
# animation support:
|
||||||
self.animation = None
|
self.animation = None
|
||||||
self.deferred_raises = []
|
self.deferred_raises = []
|
||||||
|
self.deferred_pos = []
|
||||||
|
|
||||||
ed = kwargs['image']
|
ed = kwargs['image']
|
||||||
size = ed.size
|
size = ed.size
|
||||||
|
@ -369,23 +370,37 @@ class MfxCanvasImage(object):
|
||||||
image.corePos = dpos
|
image.corePos = dpos
|
||||||
if not self.animation:
|
if not self.animation:
|
||||||
image.pos, image.size = self.canvas.CoreToKivy(dpos, dsize)
|
image.pos, image.size = self.canvas.CoreToKivy(dpos, dsize)
|
||||||
|
else:
|
||||||
|
pos, size = self.canvas.CoreToKivy(dpos, dsize)
|
||||||
|
self.deferred_pos.append(pos)
|
||||||
|
|
||||||
def makeAnimStart(self):
|
def makeAnimStart(self):
|
||||||
def animStart(anim, widget):
|
def animStart(anim, widget):
|
||||||
# print('MfxCanvasImage: animStart %s' % self)
|
# print('MfxCanvasImage: animStart %s' % self)
|
||||||
for cb in self.deferred_raises:
|
|
||||||
cb()
|
|
||||||
self.deferred_raises = []
|
|
||||||
|
|
||||||
|
# raise to top if reqested for this move
|
||||||
|
if self.deferred_raises:
|
||||||
|
self.deferred_raises[0]()
|
||||||
|
self.deferred_raises = self.deferred_raises[1:]
|
||||||
|
|
||||||
|
# fix destination position (hack into animation class - not nice)
|
||||||
|
if self.deferred_pos:
|
||||||
|
widgets = anim._widgets
|
||||||
|
for uid in list(widgets.keys()):
|
||||||
|
anim = widgets[uid]
|
||||||
|
p = anim['properties']
|
||||||
|
# print (p)
|
||||||
|
p['x'] = (p['x'][0], self.deferred_pos[0][0])
|
||||||
|
p['y'] = (p['y'][0], self.deferred_pos[0][1])
|
||||||
|
# print (p)
|
||||||
|
self.deferred_pos = self.deferred_pos[1:]
|
||||||
return animStart
|
return animStart
|
||||||
|
|
||||||
def makeAnimEnd(self, dpos, dsize):
|
def makeAnimEnd(self, dpos, dsize):
|
||||||
def animEnd(anim, widget):
|
def animEnd(anim, widget):
|
||||||
# print('MfxCanvasImage: animEnd %s' % self)
|
# print('MfxCanvasImage: animEnd %s' % self)
|
||||||
self.animation = False
|
self.animation = False
|
||||||
self.deferred_raises = []
|
# print('MfxCanvasImage: animEnd moved to %s, %s' % (dpos[0], dpos[1])) # noqa
|
||||||
image = self.image
|
|
||||||
image.pos, image.size = self.canvas.CoreToKivy(dpos, dsize)
|
|
||||||
return animEnd
|
return animEnd
|
||||||
|
|
||||||
def animatedMove(self, dx, dy, duration=0.2):
|
def animatedMove(self, dx, dy, duration=0.2):
|
||||||
|
@ -745,28 +760,29 @@ class MfxCanvas(LImage):
|
||||||
if (itm is not None):
|
if (itm is not None):
|
||||||
if (abitm is None):
|
if (abitm is None):
|
||||||
# print('MfxCanvas: tag_raise: to top')
|
# print('MfxCanvas: tag_raise: to top')
|
||||||
self.clear_widgets([itm])
|
self.remove_widget(itm)
|
||||||
self.add_widget(itm)
|
self.add_widget(itm)
|
||||||
else:
|
else:
|
||||||
print('MfxCanvas: tag_raise: to specified position')
|
# print('MfxCanvas: tag_raise: to specified position')
|
||||||
ws = []
|
self.remove_widget(itm)
|
||||||
for c in reversed(self.children): # reversed!
|
k = self.children.index(abitm)
|
||||||
if c != itm and c != abitm:
|
self.add_widget(itm, index=k)
|
||||||
ws.append(c)
|
|
||||||
if c == itm:
|
|
||||||
continue
|
|
||||||
if c == abitm:
|
|
||||||
ws.append(abitm)
|
|
||||||
ws.append(itm)
|
|
||||||
self.clear_widgets()
|
|
||||||
for w in ws:
|
|
||||||
self.add_widget(w)
|
|
||||||
|
|
||||||
def tag_lower(self, id, belowThis=None):
|
def tag_lower(self, itm, belowThis=None):
|
||||||
print('MfxCanvas: tag_lower(%s, %s)' % (id, belowThis))
|
print('MfxCanvas: tag_lower(%s, %s)' % (itm, belowThis))
|
||||||
# y = self.yy # kommt das vor ?
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
if (itm is not None):
|
||||||
|
if (belowThis is None):
|
||||||
|
# print('MfxCanvas: tag_lower: to bottom')
|
||||||
|
self.remove_widget(itm)
|
||||||
|
k = len(self.children.index)
|
||||||
|
self.add_widget(itm,index=k)
|
||||||
|
else:
|
||||||
|
# print('MfxCanvas: tag_lower: to specified position')
|
||||||
|
self.remove_widget(itm)
|
||||||
|
k = self.children.index(belowThis)
|
||||||
|
k += 1
|
||||||
|
self.add_widget(itm, index=k)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Reference in a new issue