Keyframe help

Hi, I have a little problem with a runner in a game



In the code below we want it so that once the keyInputAction is over the model returns to keyframe 40 or ideally another keyframe altogether. Is it possible to set an action in the inpurhandler for no input being present, or maybe something at the end of this code for when it is over?


    public class RunningGirl extends KeyInputAction
    {
        public void performAction(InputActionEvent evt)
        {
            if (key.getCurrentFrame() >= 66 && key.getCurrentFrame() < 70)
            {
                return;
            }
            if (key.getCurrentFrame() >= 40 && key.getCurrentFrame() < 44)
            {
                return;
            }
            key.setRepeatType(KeyframeController.RT_CLAMP);
            key.setSpeed(5.0f);
            key.setNewAnimationTimes(40,45);
        }
    }



I am quite new to JME, and if this doesn't make sence I can try and rephrase it.

Cheers!

not getting any responces, so either what is said was really stupid, or really hard…?



on the same not but from a different angle is it possible to do something like this:


      
            KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager();
                keyboard.set("menu", KeyInput.KEY_ESCAPE);
      keyboard.set("exit", KeyInput.KEY_Q);
      keyboard.set("null", null);



where "keyboard.set("null", null);" is the action to happen when no key is pressed?

I don't think I understand your question…you want something to continually happen when there are no keys being pressed?



If so, you don't want to constantly throw out events to an input handler, you'd most likely do that in your update method.  You could use something like setting a boolean to true when a key is pressed, and then setting it to false when released - check that boolean in your update and if it's true, don't do whatever it is you're doing.

What you just said is exactly what i want to do, how do i set an "on release" functions?

Check out "jmetest.input.TestInputHandler".  It has a nice example on how to do exactly that.



For quick reference, here's some code from that class (though I'd still check the class itself!):


        InputAction buttonAction = new InputAction() {
            public void performAction( InputActionEvent evt ) {
                String actionString;
                if ( !evt.getTriggerAllowsRepeats() ) {
                    actionString = evt.getTriggerPressed() ? "pressed" : "released";
                } else {
                    actionString = "down";
                }
                text1.print( evt.getTriggerDevice() + " " + evt.getTriggerName() + " (" + evt.getTriggerIndex() + ":" + evt.getTriggerCharacter() + ") " +
                        actionString + " on " + timer.getTime() );
            }
        };




Good luck!