Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change width of sprite dynamically but i can't perform it.!! Here i want to change only my white sprite i want to use these type of facility in my game in using AndEngine I want to display life of player

enter image description here

share|improve this question
up vote 5 down vote accepted

I add my code its for temporary code you can change this code set your life of player

    life = 10;
    final Sprite whiteSprite= new Sprite(0, 0, testRegion);
    width = whiteSprite.getWidth();
    scale = width/life;

    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        public void run() {
            if (width > 0) {
    }, 5000, 1000);
share|improve this answer
Thanks a lot . It's working fine.. – Maan Apr 3 '13 at 9:43

I finally found how you can change width or height with modifiers of andengine. Don't think you need it now. But it can be helpful for others.

entity.registerEntityModifier(new SingleValueSpanEntityModifier(duration, fromHeight, toHeight) {
        protected void onSetInitialValue(IEntity pItem, float pValue) {}
        protected void onSetValue(IEntity pItem, float pPercentageDone, float pValue) {
            //where CLASS is the class of your item (Rectangle or Sprite...)
            //as Entity class hasn't width and hight params.
            // pValue is a variable from modifier. So, you write it like that.
        public IEntityModifier deepCopy() throws DeepCopyNotSupportedException {return null;}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.