How to Use sourcerect
by Jebaraj Daniel · in Torque Game Builder · 07/29/2011 (11:51 pm) · 3 replies
In my game loading has take lot of time to load, how to define sprites with use of sourcerect, i did't find any clue... if anybody know, pls tell
#2
And for breaking image maps there is CELL mode.
08/02/2011 (8:30 am)
SourceRect has nothing to do with loading.And for breaking image maps there is CELL mode.
#3
08/02/2011 (6:32 pm)
I think he means he would like to load one imagemap (or fewer imagemaps) containing all the sprites he needs, then cut out the sprites he needs for each object. I forgot that you could simply break imagemaps into cells, and that is probably a much easier approach to this. :p
Torque Owner Justin Proffitt
sourceRect: xPixelOffset yPixelOffset pixelWidth pixelHeight;
The width and height are of the cell you wish to cut out of the imageMap, and the x and y offset are offset from the top left corner.
So to break a 32x32 imagemap up into 4 16x16 pieces, here is what you would define sourceRect as for each piece.
Top left corner:
"0 0 16 16"
Top right corner:
"16 0 16 16"
Bottom left corner:
"0 16 16 16"
Bottom right corner:
"16 16 16 16"
Does that help? For some reason I am having trouble explaining it, it's basically defining cell coordinates and dimensions.