Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Barcik on Thu 17/04/2003 14:57:44

Title: CenterObject(int object)
Post by: Barcik on Thu 17/04/2003 14:57:44
I'd like to suggest the function in the topic. Similar to CenterGUI, except that it center objects.
Title: Re:CenterObject(int object)
Post by: Ishmael on Thu 17/04/2003 16:28:13
 ;D
Title: Re:CenterObject(int object)
Post by: AJA on Thu 17/04/2003 18:30:13
I presume you mean centering GUI objects, right?
Title: Re:CenterObject(int object)
Post by: Barcik on Thu 17/04/2003 18:44:09
No, I do mean centering objects.
Title: Re:CenterObject(int object)
Post by: AJA on Thu 17/04/2003 18:51:26
Room objects? But... May I ask you why you need to center room objects?
Title: Re:CenterObject(int object)
Post by: Barcik on Thu 17/04/2003 18:52:38
Mostly for credits.

I do know a way to do this myself, but I think this can be useful to implement and it seems quite trivial to me.
Title: Re:CenterObject(int object)
Post by: AJA on Thu 17/04/2003 18:55:47
Use Creditz plugin... by me... ;D
Title: Re:CenterObject(int object)
Post by: scotch on Thu 17/04/2003 19:14:30
If anyone else wants to do it in the meantime, i used this script.

function CenterObject(int object,int widthofobject,int heightofobject)
{
int xp=(((320-widthofobject)/2)+GetViewportX());
int yp=(((200+heightofobject)/2)+GetViewportY());
SetObjectPosition (object, xp, yp);
}

I can't script well but it seems to work ok..
Title: Re:CenterObject(int object)
Post by: Pumaman on Thu 17/04/2003 19:17:02
I can't really see this being useful enough to be added - after all, custard's script should do it. Is there a use for this that I'm not thinking of?
Title: Re:CenterObject(int object)
Post by: Barcik on Thu 17/04/2003 22:33:53
In that case may I suggest GetObjectWidth and GetObjectHeight?
Title: Re:CenterObject(int object)
Post by: scotch on Fri 18/04/2003 12:35:04
Heh, I was going to ask that, or at least get an image's height,  there's already a function to find which sprite an object is set to.
I can't really think of a real use for it though, unless you're setting the object image to a random sprite and you don't know the heights but that seems unlikely.
Title: Re:CenterObject(int object)
Post by: Privateer Puddin' on Fri 18/04/2003 13:04:23
Quote from: CJ on Thu 17/04/2003 19:17:02
I can't really see this being useful enough to be added - after all, custard's script should do it. Is there a use for this that I'm not thinking of?

Thanks, but its not mine :)
Title: Re:CenterObject(int object)
Post by: scotch on Fri 18/04/2003 13:30:33
I stole it from you and slightly modified it.
How did CJ know that?!
Title: Re:CenterObject(int object)
Post by: Pumaman on Fri 18/04/2003 14:32:29
Quote from: custard on Fri 18/04/2003 13:04:23
Thanks, but its not mine :)

Err... sorry about that scotch, I must have had custard on the brain at the time. Mmmmmm, treacle pudding with custard.

*ahem* anyway, yes I think a GetSpriteHeight/Width would be useful, and you could use it in conjunction with GetObjectGraphic to do what you're asking here.
Title: Re:CenterObject(int object)
Post by: RickJ on Sat 19/04/2003 17:48:29
How about characters?  Would GetCharacterGraphic() also be useful?
Title: Re:CenterObject(int object)
Post by: Pumaman on Sat 19/04/2003 18:12:43
Possibly - but characters are altogether more complicated since they might be scaled, then the GetSpriteWidth wouldn't return the actual width of the character. Would anybody actually find a script function like that useful?
Title: Re:CenterObject(int object)
Post by: Scorpiorus on Sat 19/04/2003 21:09:07
I find it pretty useful for doing imagesize-related stuff. I could use plugin API but implementing the function into AGS directly would help to keep the things portable. That's always handy to have one more Get*thingy* function. :P

-Cheers