Display an icon over a character (SOLVED)

Started by alkis21, Thu 03/08/2006 10:57:35

Previous topic - Next topic

alkis21

On some occasions, I want to have an animated object (a lightbulb) displayed briefly a few pixels over a character.
I thought it would simply be a case of displaying the object at player.x, player.y-... But this idea does not work in rooms with scalable walking areas, for obvious reasons: when the character is at 80% zoom, the object appears a few pixels above him, but if he's at 60% zoom it appears way above him.
Any ideas on how to solve this?

Gilbert

Something like below (you may need to figure out the true values though) ?

object[5].Y = cEgo.y - ((cEgo.Scaling * 30)/100);

SSH

Make a new character view with the lightbulb? You could have the character look pensive then lightbulb appears then character looks happy...
12

alkis21

Quote from: SSH on Thu 03/08/2006 14:25:47
Make a new character view with the lightbulb? You could have the character look pensive then lightbulb appears then character looks happy...

I tried that too, but the result was not satisfactory because the object looked zoomed out as well.
I'll try Gilbot's suggestion, it sounds like it will take me some time to get it right but it sounds doable.

Ashen

#4
What about:

Code: ags

function GetScale() {
  int aHeight = GetGameParameter (GP_SPRITEHEIGHT, GetGameParameter (GP_FRAMEIMAGE, player.View, player.Loop, player.Frame), 0, 0); // Add an amount here ('aHeight = GetGame........... + 5') to have it a scaled amount above his head
  float pScale = IntToFloat(player.Scaling)/100.0;
  pScale = pScale*IntToFloat(aHeight);
  return FloatToInt(pScale);
}

...

object[5].Y = player.y - GetScale(); // Or 'player.y - (GetScale() + 5)' to have it a fixed amount above his head


The float is used for accuracy - you could try it with an int, but I'm not sure how it'd turn out. Probably not very well, I think it'd always return the normal, 100%, height or 0.
I know what you're thinking ... Don't think that.

alkis21

Thanks Ashen, your suggestion worked as usual.
By the way, I added

Code: ags
import function GetScale();


in the Script Header, that was what I was supposed to do, wasn't it?

Ashen

Only just seen this, but I'll post for completeness:

It depends. If you want to be able to use GetScale() in room scripts, then yes, you need to import it in the header. If you just need to use it in the Global Script, called in rep_ex(_always) (which I assumed was the case), then you don't NEED to import it, but it does no harm.
I know what you're thinking ... Don't think that.

alkis21

That's what I thought, cheers. I do want to use it in room scripts.

SMF spam blocked by CleanTalk