Scrolling Game Development Kit Forum

SGDK Version 2 => Help, Errors, FAQ => Topic started by: Vincent on 2009-03-10, 04:33:45 PM

Title: Changing sprite size at runtime
Post by: Vincent on 2009-03-10, 04:33:45 PM
Hi guys, I've got another question.

Is there a way to resize a sprite at runtime? 

I'm explaining why I want to accomplish that.  In my game, I want the main character to have a life gauge on a overlay map.  When the character gets healed or damaged, I update a counter. The life gauge is associated with the counter.  So, let's say the counter max value = 100 and the actual value = 50, I want the life gauge to be at 50% of its total height.  I know I could accomplish that by switching the state of the life gauge for a set of pre-defined sizes, but it would make a lot of graphics, a lot of states and a lot of rules.

I don't see a width or height property for a sprite, so I can't write a custom function to do this.  Have I missed something?   :suspious:

Thanks! :)
Title: Re: Changing sprite size at runtime
Post by: SmartBoy16 on 2009-03-10, 05:22:32 PM
is there a "Repeat Icon to right" function like in SGDK1?
Title: Re: Changing sprite size at runtime
Post by: Jam0864 on 2009-03-10, 11:36:22 PM
I think in the frameset there is options for resizing. not 100% sure.

For the life guage, you could draw the bar empty on a non-scrolling layer, then make a 1px wide image as a sprite, then duplicate a heap of those next to each other based on how large the value of a variable is.
Title: Re: Changing sprite size at runtime
Post by: bluemonkmn on 2009-03-11, 05:48:09 AM
Did you see the DrawCounterAsTile function?  It's demonstrated in the sample game.  In the Overlay map in the sample game, look at the plan "Cherries".
Title: Re: Changing sprite size at runtime
Post by: Vincent on 2009-03-11, 07:39:34 AM
Oh, I didnt' realize that the sample game "cherries" could be rearranged into a gauge, but now that you mention it, it makes sense.   :-[
I will take a closer look into the sample game.

Thanks for your help guys!  :)



Title: Re: Changing sprite size at runtime
Post by: Vincent on 2009-03-11, 07:19:21 PM
Yup, DrawCounterAsTile solved my problem.  Thanks! :D