Sunday, November 01, 2009

Case 07 - New class, enemy

In this case we had make a new class and a object/enemy that would follow and execute a action when colliding with our main character. I didn't really look into it before wednesday, tried to look into some of my books without understanding much. I found a example on fronter, which I think was uploaded by mistake since it was removed later. Allthough, it was a clean example and with that I could figure out how to create a new class and make it work together with my main class file. Also the basic enemy AI in that example worked just as I intended my enemy to behave, with modifications and additional lines of course. I added gravity and velocity, taken from the main class, and made it so that when the enemy is at the same x-coordinate as the character it plays the idle animation. When colliding it plays a attack animation and resets the pirates position.
I had a little problem with my enemy, when it collided with my character it wouldn't stop attacking and start following again. So one of research assistants/tutors gave me a tip about timer events and showed the basics to set it up on the fridays workshop. Though, I forgot some minor details and had to look it up to succesfully add a timer to my enemy AI. I found a forum thread where someone got help to set up a timer, and I found out that my timer code just had some minor faults.

The lab class for this case were informative and helpfull to further understand classes and basic AI to make objects follow other objects.

Forum thread that helped me out with timer: http://www.actionscript.org/forums/showthread.php3?p=926165

No comments: