下面是一个sprite behavior,sprite的初值在score中设定。放大效果可依自已要求自行加入。
property pTimeTotal,pOtime
property pDestX,pDestY
property pOloc
property pThissprite
property pMove
on getpropertydescriptionlist me
plist=[:]
addProp plist, #PDestX, [#default: 0, #format:#integer, #comment: "目标点的横坐标:"]
addProp plist, #PDestY, [#default:0, format: #integer, #comment: "目标点的纵坐标:"]
addProp plist,#pTimeTotal,[#default:60,format:#integer,#comment: "总的移动时间:"]
return plist
end
on beginsprite me
pThissprite=sprite(me.spriteNum)
pOtime=the ticks
pOloc=pThissprite.loc
pmove=true
end
on exitframe me
if pmove then
timepast=the ticks- pOtime
if timepast
dloc=(point(pDestX,pDestY)-pOloc)*timepast/pTimetotal
pThissprite.loc=pOloc+dloc
else
pmove=false
pThissprite.loc=point(pDestX,pDestY)
end if
end if
end