1. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Question - Changing Sprite frames

Discussion in 'Modding Help' started by jwoo2023, Nov 22, 2013.

  1. jwoo2023

    jwoo2023 Shopkeep Stealer

    Messages:
    48
    How would I change the sprite frame when an entity is on or below a set value of health? Such as when a building is on low health, it changes frames to a broken down one.
     
  2. Skinney

    Skinney THD Team THD Team Forum Moderator Tester

    Messages:
    468
    Below I have detailed a basic way to do it, I would recommend looking at "GenericHit.as" for a better understanding/way to make it work for you and the functionality you have envisioned.

    Code:
    // Whatever header would be most appropriate for your situation
    
    if (this.getHealth() < 1)
    {
         CSprite@ sprite = this.getSprite(); // This isn't necessary if you're using a CSprite header
         sprite.SetFrame(1); // Insert the frame you want here
    }
     
  3. jwoo2023

    jwoo2023 Shopkeep Stealer

    Messages:
    48
    By the way, comments are '#' not '//' :D
    --- Double Post Merged, Nov 22, 2013, Original Post Date: Nov 22, 2013 ---
    Also, it glitches out, because it goes to that sprite frame then goes back to the one in the default loop.
     
  4. jackitch

    jackitch :(){ :|: & };: Global Moderator Donator Tester
    1. SharSharShar - [SHARK]

    Messages:
    249
    @jwoo2023

    FYI, comments aren't always '#', that's just in the one case that you've been considering (probably cfg's right?). In KAG's Angelscript files, as with many other programming languages, comments are implied with double forward slashes '//' or for multiple lines with /* to open and */ to close.
     
  5. jwoo2023

    jwoo2023 Shopkeep Stealer

    Messages:
    48
    Oh, I see, but when I got rid of the comments, the game stopped glitching, with it the entity glitched.
    --- Double Post Merged, Nov 29, 2013, Original Post Date: Nov 22, 2013 ---
    When ever it's down on low health, the sprite glitches out and switches back to the default_loop animation. D: help pls?