Cocos2d-x to achieve the game monster blood strip
Recently, cocos2d requires blood in demand. By the way
First, write a method by yourself.
// Monster blood strip
Void Fighting: getBloodbar (MenuItemImage * guaisprite, float a) {// guaispirte is a parameter of the monster genie
CCSprite * pBloodKongSp = CCSprite: create ("B .png"); // empty blood record
PBloodKongSp-> setPosition (Vec2 (guaisprite-> getContentSize (). width/2, guaisprite-> getContentSize (). height/1.1 ));
Guaisprite-> addChild (pBloodKongSp );
CCSprite * pBloodManSp = CCSprite: create ("z.png"); // full blood
CCProgressTimer * pBloodProGress = CCProgressTimer: create (pBloodManSp );
PBloodProGress-> setType (kCCProgressTimerTypeBar );
PBloodProGress-> setBarChangeRate (Vec2 (1, 0 ));
PBloodProGress-> setMidpoint (Vec2 (0, 0 ));
PBloodProGress-> setPosition (Vec2 (guaisprite-> getContentSize (). width/2, guaisprite-> getContentSize (). height/1.1 ));
PBloodProGress-> setPercentage ();
Guaisprite-> addChild (pBloodProGress, 1, 1 );
}
You can directly call the Pass Parameter in init to use
This-> getBloodbar (guan1, 20366f );