Rectangle Object or Rectangle Image resize

Dear gurus,

I am thinking to create a street fighter like HP bar. Whenever the play get hit, the HP bar will reduce.
So, player 1, Left side will have have a HP bar, left top of the screen.

But what’s stopping me is… the ‘reduce hp’ always based on center reference point, so the shrink of the image doesn’t really look nice

 local function testHPReduce()  
 print('In Function testHPReduce()')  
 local g = graphics.newGradient(  
 { 0, 255, 0 },  
 { 200, 0, 0 },  
 "right" )  
  
 -- sets gradient 'g' on rect  
 local rect = display.newRect( 0, 0, 480, 100 )  
 rect:setFillColor( g )   
  
 transition.to(rect, {time = 1000, width = 200})  
  
 end  

can someone show me how to fix this?

Thanks [import]uid: 10373 topic_id: 30593 reply_id: 330593[/import]

Easiest way is probably set the reference point to be the left or right side(depending on which way the health bar shrinks). If it doesn’t shrink the way you want it is easy to just do a g.x = 50 after your HP goes down to reposition it.

http://docs.coronalabs.com/api/type/DisplayObject/setReferencePoint.html
[import]uid: 147305 topic_id: 30593 reply_id: 122634[/import]

Easiest way is probably set the reference point to be the left or right side(depending on which way the health bar shrinks). If it doesn’t shrink the way you want it is easy to just do a g.x = 50 after your HP goes down to reposition it.

http://docs.coronalabs.com/api/type/DisplayObject/setReferencePoint.html
[import]uid: 147305 topic_id: 30593 reply_id: 122634[/import]