Blender Game Engine Python Flipper Animation Okay. I've been working on this 2D Platform game in the Blender Game Engine lately. I've added some basic motion functions (in Python code), and now I'm getting to animation. I'm using the Blender playAnimation() function, and it works. But, I've found with logic bricks that the animation type that works best in my game is the flipper type. playAnimation() has no flipper mode.

Here's my script so far: (without playAnimation() function in it)

import bge
import math

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    keyboard = bge.logic.keyboard

    xyz = own.localOrientation.to_euler()
    xyz[2] = math.radians(180)

    if bge.logic.KX_INPUT_ACTIVE == keyboard.events
       [bge.events.RIGHTARROWKEY]:
       own.applyMovement((0, 0.08, 0), True)
       own.worldOrientation = (0, 0, 0)

    if bge.logic.KX_INPUT_ACTIVE == keyboard.events
       [bge.events.LEFTARROWKEY]:
       own.applyMovement((0, 0.08, 0), True)
       own.localOrientation = xyz.to_matrix()

    if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.SPACEKEY]:
        own.applyMovement = ((0, 0, 0.08), True)

main()


So, how could I allow flipper animations in this script? Thanks!!

P.S. This code is for a public game project (or several). While I'll really appreciate any code or tips offered, I may or may not be able to give credit for it.
The flipper mode belongs to the action armature. This makes the actuator play the animation forward on activation and backward on deactivation.

The actuator uses the internal animation system to play the action in response the the current status (activated or deactivated) and the animation status (playing, reaching end).

The internal animation system can only act according to the animation status. 

The simplest solution is to activate/deactivate the action actuator in flipper mode.

E.g.:

import bge
import math

controller = bge.logic.getCurrentController()
owner = controller.owner

keyboard = bge.logic.keyboard

xyz = owner.localOrientation.to_euler()
xyz[2] = math.radians(180)

if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.RIGHTARROWKEY]:
    owner.applyMovement((0, 0.08, 0), True)
    owner.worldOrientation = (0, 0, 0)
    controller.activate("turn right")
    controller.deactivate("turn left")
    controller.deactivate("jump")

if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.LEFTARROWKEY]:
    owner.applyMovement((0, 0.08, 0), True)
    owner.localOrientation = xyz.to_matrix()
    controller.activate("turn left")
    controller.deactivate("turn right")
    controller.deactivate("jump")

if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.SPACEKEY]:
    owner.applyMovement = ((0, 0, 0.08), True)
    controller.activate("jump")
    controller.deactivate("turn right")
    controller.deactivate("turn left")