Hi,
Im trying to make a nice status bar by anchoring an image within a container and then resizing the container as your health decreases / increases.
I’ve anchored everything to the left, but my status bar image keeps getting clipped on both sides when I resize the container down. Its like its re-centering the container even though I have it anchored at zero.
Any ideas? Thanks, Greg
energycontainer = display.newContainer(380, 15 )
energycontainer.anchorX = 0
energycontainer:translate( _W /2-145, _H-57 ) – center the container
energycontainer.anchorChildren =true
statusenergy = display.newImageRect(GuiGroup, “images/statusled.png”, 380,15)
energycontainer:insert( statusenergy, true)
statusenergy.anchorX=0
statusenergy:translate (-195,0)
statusenergy:toFront()
shieldcontainer = display.newContainer(250, 15 )
shieldcontainer.anchorX = 0
shieldcontainer:translate( _W /2-145, _H-26 ) – center the container
shieldcontainer.anchorChildren =true
statusshields = display.newImageRect(GuiGroup, “images/statusled.png”, 380,15)
shieldcontainer:insert( statusshields, true)
statusshields.anchorX=0
statusshields:translate (-125,0)
statusshields:toFront()
and here is my gameloop code to resize:
local healthScale = energy/maxenergy * 350
energycontainer.width = healthScale
local healthScale = shields/maxshields * 250
shieldcontainer.width = healthScale