Questions About Source Rects
by Joe Virgin · in iTorque 2D · 03/10/2010 (1:18 pm) · 0 replies
I'm trying to employ source rectangles as an optimization into one of my games and I'm coming to some obstacles in using them.
First, I've noticed that if you load an image through a game script, instead of through a level file, you cannot use a global variable for the sourceRect field with T2D breaking.
Secondly, I'm having trouble replacing the setImageMap method using source rectangles, is there a setSrcRectangle and getSrcRectangle?
Edit:
Nevermind, I figured it out.
First part was a problem on my end.
Second part figured out by guessing the method - object.setSourceRect(%x, %y, %width, %height)
While strangely enough there isn't an object.getSourceRect(), you can just use the object.sourceRect field.
First, I've noticed that if you load an image through a game script, instead of through a level file, you cannot use a global variable for the sourceRect field with T2D breaking.
Secondly, I'm having trouble replacing the setImageMap method using source rectangles, is there a setSrcRectangle and getSrcRectangle?
Edit:
Nevermind, I figured it out.
First part was a problem on my end.
Second part figured out by guessing the method - object.setSourceRect(%x, %y, %width, %height)
While strangely enough there isn't an object.getSourceRect(), you can just use the object.sourceRect field.
About the author
Joe Virgin is a programmer for Plainvue Software, Inc., a company producing iPhone games that teach math skills to the youth. Check out Fraction's Kitchen Lite, Fortune's Prime, and Chainshooter powered by iTGB and now available on the App Store.