Hello, I am having trouble switching between two animations when key is pressed. I have two classes for each animation. Can anyone be kind enough to show me an example or explain how it should be coded.
Thanks!
Hello, I am having trouble switching between two animations when key is pressed. I have two classes for each animation. Can anyone be kind enough to show me an example or explain how it should be coded.
Thanks!
hello,
say you have 2 animations :
anim1.draw();
anim2.draw();
you can chose the animation like so :
// ofApp.h
int animToPlay;
//ofApp::setup()
animToPlay = 0;
// ofApp::draw()
switch (animToPlay) {
case 1 : anim1.draw(); break;
case 2 : anim2.draw(); break;
default : //whatever
}
// ofApp::keyPressed()
void ofApp::keyPressed(int key){
if(key == 'a') {
animToPlay = 1;
}
if(key == 'b') {
animToPlay = 2;
}
}
then use key ‘a’ or ‘b’ to change the animation
Like so you can use any key to trigger any animation. if you only have 2 animations, code could be simpler.