Solo-Ion
Dungeon Spirit
Loading textures at runtime like you are doing there is really not a good way to do it. If you are writing your own animation AI, you could just put both variations into the one texture and adjust your AI accordingly. But if you have no control over the animation, you'll need to load it in once when the mods are loaded then access it from there.I've spent the last day and a half trying to do this. I've looked at examplemods, tutorials, even the source code itself. I just want to at half health (5000 hp), have my boss change sprites. I know it's something simple or my code has one thing off, so if anyone can, please help me.
Here's the code that i've been using:
//Boss second stage texture
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
{
if (npc.life <= 5000)
{
spriteBatch.Draw(mod.GetTexture("NPCs/Boss/BigBoy2"), npc.Center, null, Color.Red * (255f / 255f), 0f, new Vector2(100, 100), 3f, SpriteEffects.None, 0f);
}
return true;
}
I should also mention i'm new to this so ;p
In your main mod class, create something like this.
Code:
public static Texture2D[] nameOfTexture;
public override void Load()
{
nameOfTexture = GetTexture("NPCs/Boss/BigBoy2");
}
Code:
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
{
if (npc.life <= 5000)
{
spriteBatch.Draw(YourModsName.nameOfTexture, npc.Center - Main.screenPosition, null, Color.Red * (255f / 255f), 0f, new Vector2(100, 100), 3f, SpriteEffects.None, 0f);
return false; //DON'T draw the normal boss texture
}
return true;
}