Game Development Community

RC1 - KEY'd sprites squashed

by Tom Spilman · in Torque Game Builder · 06/02/2006 (1:40 pm) · 6 replies

I thought this was fixed, but it doesn't seem like it. We're trying to use the KEY image mode to pack together a bunch of different images.

www.sickheadgames.com/stuff/keymode_t.jpg

This seems to be correctly made to the specifications in the TDN tutorial.

Now when i add the image map and try to use frames from it, all my sprites come out squashed.

www.sickheadgames.com/stuff/squished_t.jpg

Of course i could unsquish them manually, but that is tedious and error prone. From testing it seems to apply the aspect ration from the first cell in the map to all the other cells.

Am i doing something wrong here? This seems like a bug to me.

About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.


#1
06/02/2006 (3:27 pm)
I feel bad for not being able help out the last 2 days... Here is a fix for this:

in levelBuilderStaticSpriteTool.cc:
Point2I LevelBuilderStaticSpriteTool::getPixelSize()
{
   t2dStaticSprite* staticSprite = dynamic_cast<t2dStaticSprite*>(mCreatedObject);
   if (staticSprite)
   {
      t2dImageMapDatablock* imageMap = dynamic_cast<t2dImageMapDatablock*>(Sim::findObject(staticSprite->getImageMapName()));
      if (imageMap)
      {
         [b]const U32 frame = staticSprite->getFrame();[/b]
         const t2dImageMapDatablock::cFramePixelArea& area = imageMap->getImageMapFramePixelArea([b]frame[/b]);
         return Point2I(area.mWidth, area.mHeight);
      }
   }

   return Parent::getPixelSize();
}

I have not tested it but it should work. Thanks for the Torsion update ;)

-Michael

EDIT: I've added this to the bug tracker. I guess this will be fixed in the next release then.
#2
06/02/2006 (5:33 pm)
Wow... that's a tremendously simple fix. Thanks a ton, Michael. Now i hope this can get into the release. =)
#3
06/02/2006 (10:03 pm)
Michael,
Another great fix, thanks a bunch I've added this to the repo for the release.

Cheers,
-Justin
#4
06/05/2006 (10:45 am)
Ok a related bump to this thread. The fix corrects the size ratio when you drop in your sprites, but the image on the button is still squashed:

www.sickheadgames.com/stuff/squish2.png

It's not a show stopper, but it does make it a little difficult to find the right frame at times. I tried fixing it myself, but i couldn't find where this stuff was in the code.
#5
06/05/2006 (4:59 pm)
The fix. Put this on line 224 of tools\leveleditor\scripts\forms\objectlibrary\objectLibraryBaseType.ed.cs (at the end of the "t2dStaticSprite" case):
%object.setSize( %datablockName.getFrameSize( %currentFrame ) );
Thanks for reporting these Tom.
#6
06/05/2006 (6:55 pm)
That works great! You guys sure know the TGB code base much better than i do. =)