I'd like to suggest the function in the topic. Similar to CenterGUI, except that it center objects.
;D
I presume you mean centering GUI objects, right?
No, I do mean centering objects.
Room objects? But... May I ask you why you need to center room objects?
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.
Use Creditz plugin... by me... ;D
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..
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?
In that case may I suggest GetObjectWidth and GetObjectHeight?
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.
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 :)
I stole it from you and slightly modified it.
How did CJ know that?!
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.
How about characters? Would GetCharacterGraphic() also be useful?
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?
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