It looks like you're new here. If you want to get involved, click one of these buttons!
orxOBJECT *pstIcon;
// Gets its icon
pstIcon = orxOBJECT(orxHashTable_Get(mpstEnemyTable, orxString_ToCRC(_roEnemy.GetName())));
// Valid?
if(pstIcon)
{
orxGRAPHIC *pstGraphic;
// Gets its graphic object
pstGraphic = orxOBJECT_GET_STRUCTURE(pstIcon, GRAPHIC);
// Valid?
if(pstGraphic)
{
orxFLOAT fHealthRatio, fShift;
orxVECTOR vPivot, vSize, vOrigin;
// Gets enemy's health ratio
fHealthRatio = _roEnemy.GetHealth() / _roEnemy.GetMaxHealth();
// Pushes its section
orxConfig_PushSection(orxObject_GetName(pstIcon));
// Gets its original pivot, origin & size
orxConfig_GetVector(szConfigIconPivot, &vPivot);
orxConfig_GetVector(szConfigIconOrigin, &vOrigin);
orxConfig_GetVector(szConfigIconSize, &vSize);
// Pops config section
orxConfig_PopSection();
// Gets shift value
fShift = orxMath_Ceil(vSize.fY * (orxFLOAT_1 - fHealthRatio));
// Updates pivot, origin & size according to health
vPivot.fY -= fShift;
vOrigin.fY += fShift;
vSize.fY -= fShift;
// Applies them
orxGraphic_SetPivot(pstGraphic, &vPivot);
orxGraphic_SetOrigin(pstGraphic, &vOrigin);
orxGraphic_SetSize(pstGraphic, &vSize);
Comments
Hi lasmus, and welcome here!
As for your problem, you need to get the current animation frame's graphic, not the base one. So instead of:
Try something like:
Let me know if it works!
Did not get it to work properly yet.
If I understand correctly I should do this for every frame of the animation? Maybe im still missing something
lasmus
Can you give me more details about what didn't work?
Now I'm calling the scaling function from update function and at first animation is flickering (its like showing up in two different positions at the same time. ) and after about one cycle of animation it shows correctly? I dont know is that explained correctly. Maybe its just something that I dont understand. Can you help
Regards,
Lassi
Would you mind posting your code/config here or send me all your files by email (my address is in the README file)?
I'm pretty sure it'll be very fast to fix but it's hard to say what it is without access to your code/config.
INI-file:
Creating object and setting animation:
Generating objects according to percentage:
Then calling that in update function constantly
Hope that has some use
regards,
Lassi
Would you mind sending me somewhere a working example of the issue so that I can trace and see what's going on? I won't publish your code, of course, but if you'd rather not send it, maybe a minimal working set showing the issue then?
Thanks in advance!
Answers to those questions: All the frames are same sized and update() is called more then once for every frame.
Lassi