Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

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);
    scene.attachChild(whiteSprite);
    width = whiteSprite.getWidth();
    scale = width/life;

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

Your Answer

 
discard

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.