Topic: KeyPress!

Hi,
   

if isKeyPressed("LSHIFT") then
          do something
end

   This is not working. It seems that it does not work with shift, control also. Is there any other way for these keys presses!

Regards

Re: KeyPress!

Strange, it's working for me, at least on mac,
I'll try later on windows.

Re: KeyPress!

OK, I am using XP.

Regards.

Re: KeyPress!

it's corrected, there was a bug on windows keys,
the new code is available on SVN trunk, if you have visual studio you can build it
(just open trunk/dev/Projects/VisualStudio2005/Maratis.sln and run the build in "release").

Re: KeyPress!

Is it also a bug with "onKeyDown()" (with the maratis engine) ?

Alinor wrote:

I have some problems with the function "bool onKeydown(* char)" with keyboard symbols : the effect in maratis is quite similar to "bool isKeyPressed(* char)", I think that I should maybe use "void flush(void)" but I don't know how do it ...

Re: KeyPress!

"onKeyDown" is not affected, except for the same keys that was not recognized on windows "LSHIFT etc".

Your problem with "onKeyDown" is probably just linked with the use of "flush" yes. You need to flush the keys only after doing all your code logic, best is to put your code just after or before the script call :

If you want to call it before the script, you are not forced to redo all the update game function :

void MyGame::update(void)
{
        // put your code here

        MGame::update(void);
}

But if you want to call it after the script, you need to redo all the update function :

void MyGame::update(void)
{
        MEngine * engine = MEngine::getInstance();

        // run script
        if(engine->getScriptContext())
                engine->getScriptContext()->callFunction("onSceneUpdate");


        // put your code here


        // get level
        MLevel * level = MEngine::getInstance()->getLevel();
        if(! level)
                return;

        // get current scene
        MScene * scene = level->getCurrentScene();
        if(! scene)
                return;

        // update behaviors
        unsigned int i;
        unsigned int oSize = scene->getObjectsNumber();
        for(i=0; i<oSize; i++)
        {
                MObject3d * object = scene->getObjectByIndex(i);
                if(! object->isActive())
                        continue;
                        
                object->updateBehaviors();
        }

        // update scene
        scene->update();

        // update physics
        scene->updatePhysics();

        // update objects matrices
        scene->updateObjectsMatrices();

        // flush input
        engine->getInputContext()->flush();
}

Re: KeyPress!

I don't have vc 2005. I will wait until next release.

Regards.