Code: Select all

`image img_cursor = Transform( "img_cursor_pre" , function=MoveCursor( )`

here's my MoveCursor()

Code: Select all

```
class MoveCursor(object):
def __init__(self):
self.xspeed = 6.0
self.yspeed = 6.0
self.truex = 0
self.truey = 0
self.moving = False
def __call__(self, trans, st, at):
#trans.alpha = 0
#trans.alpha = 1
if trans.xpos is None:
trans.xpos = 120*id_hor + (id_ver %2 * 60) - 60
if trans.ypos is None:
trans.ypos = id_ver*106 - 65
xCursor = 120*id_hor + (id_ver %2 * 60) - 60
yCursor = id_ver*106 - 65
dx = abs(self.truex - xCursor)
dy = abs(self.truey - yCursor)
if self.moving == False and (dx > 0 or dy > 0):
self.truex = trans.xpos
self.truey = trans.ypos
self.moving = True
self.xspeed = 6.0
self.yspeed = 6.0
if dx > dy:
self.yspeed *= float(dy)/float(dx)
if dy > dx:
self.xspeed *= float(dx)/float(dy)
if self.moving:
if dx+dy > self.xspeed + self.yspeed:
if self.truex > xCursor + self.xspeed:
self.truex -= self.xspeed
elif self.truex < xCursor - self.xspeed:
self.truex += self.xspeed
else:
self.truex = xCursor
if self.truey > yCursor + self.yspeed:
self.truey -= self.yspeed
elif self.truey < yCursor - self.yspeed:
self.truey += self.yspeed
else:
self.truey = yCursor
trans.xpos = int( self.truex )
trans.ypos = int( self.truey )
else:
trans.xpos = xCursor
trans.ypos = yCursor
self.moving = False
global varhelp2
varhelp2 = self.truey
global varhelp3
varhelp3 = yCursor
return 0
```