pygamekit / animation.pxi

cdef enum akAnimationEvalMode:

# This wraps gkAnimationPlayer
cdef class Animation(pywrap):
    cdef gkGameObject *ob
    cdef public gkScalar blend_time
    cdef public int priority
    def play(self):
            self.blend_time, AK_ACT_END, self.priority)
    def stop(self):
    property weight:
        def __get__(self):
            return (<gkAnimationPlayer*>self._p).getWeight()
        def __set__(self,  v):
    property length:
        def __get__(self):
            return (<gkAnimationPlayer*>self._p).getLength()
        #def __set__(self,  v):
    property speed_factor:
        def __get__(self):
            return (<gkAnimationPlayer*>self._p).getSpeedFactor()
        def __set__(self, v):

cdef class AnimationList(pywrap):
    def aaa__dict__(self): # this should returna dict with all the animations, but it only returns the active one.
        cdef int hack1 "h;/*" = 0
        cdef gkAnimationsIterator it, hack2 "utHashTable<gkHashedString, gkAnimationPlayer*>::Iterator __pyx_v_it /**/"
        hack2 = (<gkGameObject*>self._p).getAnimations().iterator()
        cdef Animation a
        ret = {}
        while it.hasMoreElements():
            a = wrap(Animation, it.peekNextValue())
            a.ob = <gkGameObject*>self._p
            ret[it.peekNextKey().str().c_str()] = a
        return ret
    def __iter__(self):
        return self.__dict__().__iter__() #TODO: can be made more efficient
    def __getitem__(self,item):
        cdef Animation a
        cdef gkAnimationPlayer *ap
        ap = (<gkGameObject*>self._p).getAnimationPlayer(gkString(item))
        if ap == NULL:
            ap = (<gkGameObject*>self._p).addAnimation(gkString(item))
            if ap == NULL:
                return None
        a = wrap(Animation, ap)
        a.ob = <gkGameObject*>self._p
        return a

    def __len__(self):
        return (<gkGameObject*>self._p).getAnimations().size()