View Single Post
Seren Seren's Avatar

JCF Member

Joined: Feb 2010

Posts: 864

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

May 31, 2014, 01:13 AM
Seren is offline
Reply With Quote
A large number of objects, including those you mentioned, contain animation changes within their behavior. Those tend to reference the animation globally rather than relative to the preset one, resulting in the desired animation being displayed either occasionally or never. To reliably and permanently change sprites of such objects, the best way is to modify their behavior. It's technically possible to write a common behavior function for that and I would consider it cleaner but it will be easier to understand if there are separate ones:
Code:
void myTurtle(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::NORMTURTLE, false);
	obj.determineCurAnim(ANIM::LORI, 13);
	obj.draw();
}
void myBat(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::BAT, false);
	obj.determineCurAnim(ANIM::JAZZ, 14);
	obj.draw();
}
void myDragon(jjOBJ@ obj) {
	obj.behave(BEHAVIOR::DRAGON, false);
	obj.determineCurAnim(ANIM::SPAZ, 5);
	obj.draw();
}
Then you assign the behavior to the presets within onLevelLoad:
Code:
jjObjectPresets[OBJECT::NORMTURTLE].behavior = myTurtle;
jjObjectPresets[OBJECT::BAT].behavior = myBat;
jjObjectPresets[OBJECT::DRAGON].behavior = myDragon;
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.