#1 

29-06-2010 15:16:38

narugohan
Membres
Avatar de narugohan
Date d'inscription:
Messages: 113
IP: 86.199.112.194
Courriel

Bonjours à tous,
je suis entrain de faire un système de combat pour mon jeu, et j'ai besoin de savoir quand par exemple l'animation de mon coup de poing est terminé( quand il est arrivé au dernier frame que j'ai demandé ). Problème, je ne c'est pas comment faire.
J'ai trouvé cette fonction : "virtual void OnAnimationEnd (IAnimatedMeshSceneNode *node)=0", mais je ne comprend pas comment l'utiliser.
Si quelqu'un c'est comment l'utilisé ou à une idée pour savoir quand mon animation est temriné
Je vous en remercie d'avance

Cordialement Narugohan


PS : voici la page pour la fonction que j'ai trouvé : http://irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_i_animation_end_call_back.html#_details


Hors ligne


#2 

29-06-2010 18:16:05

narugohan
Membres
Avatar de narugohan
Date d'inscription:
Messages: 113
IP: 81.250.219.44
Courriel

c bon laissé tombé, j'ai eu une illumination xD


Hors ligne


#3 

02-07-2010 08:48:10

ramis
Membres
Date d'inscription:
Messages: 92
IP: 83.113.144.243
Courriel

Détailles un peu ton illumination, j'ai plus ou moins eu le même problême récemment :p

Hors ligne


#4 

02-07-2010 21:31:04

nabouill
Membres
Avatar de nabouill
Date d'inscription:
Messages: 242
IP: 79.92.234.161
Courriel

je connais bien un truc qui marche, mais c'est un peut bricolage. mais ça marche.
http://irrlicht-fr.org/viewtopic.php?id=1311

Hors ligne


#5 

03-07-2010 12:42:45

Zorian
Modérateurs
Date d'inscription:
Messages: 19
IP: 82.231.128.145
Courriel

J'ai trouvé comment marchait OnAnimationEnd().
Tout fonctionne bien avec ce code (qui n'est pas très interressant si ce n'est pour découvrir le fonctionnement de OnAnimationEnd).

Main.cpp

#include <irrlicht.h>
#include "CAnimationEndCallBack.h"

using namespace irr;

int main(void)
{
    IrrlichtDevice *device = createDevice (video::EDT_OPENGL, core::dimension2d<u32>(800,600),32,false,true,false,0);
    video::IVideoDriver* driver = device->getVideoDriver ();
    scene::ISceneManager *smgr = device->getSceneManager ();

    smgr->addCameraSceneNodeFPS();

    scene::IAnimatedMesh *mesh = smgr->getMesh("sydney.md2");
    scene::IAnimatedMeshSceneNode *node = smgr->addAnimatedMeshSceneNode(mesh);

    node->setFrameLoop(1,15); //on définit la boucle d'animation
    node->setLoopMode(false); //on désactive la répétition

    CAnimationEndCallBack *anim  = new CAnimationEndCallBack(); //on crée un AnimationEndCallBack
    node->setAnimationEndCallback(anim); //et on l'assigne au node

    while (device->run ())
    {
        driver->beginScene(true, true, video::SColor(255,255,255,255));
        smgr->drawAll();
        driver->endScene();
    }

    device->drop ();
    return 0;
}

CAnimationCallBack.h
#ifndef CANIMATIONENDCALLBACK_H_INCLUDED
#define CANIMATIONENDCALLBACK_H_INCLUDED

#include <irrlicht.h>

using namespace irr;

class CAnimationEndCallBack : public scene::IAnimationEndCallBack
{
    public :

    CAnimationEndCallBack();
    ~CAnimationEndCallBack();

    void OnAnimationEnd(scene::IAnimatedMeshSceneNode* node);

    private :

    bool animationFinie; 

};

#endif // CANIMATIONENDCALLBACK_H_INCLUDED

CAnimationCallBack.cpp
#include "CAnimationEndCallBack.h"


CAnimationEndCallBack::CAnimationEndCallBack() : animationFinie(false)
{
}

CAnimationEndCallBack::~CAnimationEndCallBack()
{
}

void CAnimationEndCallBack::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node)
{
    if(!animationFinie)
    {
        //tu sais que l'animation est maintenant finie, tu as un pointeur vers le node pour les modifications que tu souhaites faire
        animationFinie = true;
    }
}

Pour résumer, OnAnimationEnd est automatiquement appelé à la fin de l'animation de ton personnage si la répétition de la boucle est désactivée et si tu lui as assigné un AnimationEndCallBack.
Après, ça oblige à refaire une classe juste pour redéfinir OnAnimationEnd.


Real Programmers Don't Document - If it was hard to write, it should be hard to understand.

Hors ligne


Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
175 invités en ligne
membre en ligne: -
RSS Feed