I have a drawrect method in my main UIView which draws 8 sprites every game tic. I want to seperate out each of these sprites into a seperate UIView.
I am trying to split out one sprite first as a test.
So far I have added a UIView as subview to my main view and set it's frame. This draws a black box on the view. My question is how do I now get get the sprite drawing in the drawrect method to draw into this UIView ?
Thanks all,
Martin
Each view will need it's own drawRect, and somewhere you will need to call setNeedsDisplay on every (sub)view visible. Draw the sprite in the drawRect for the view where you want it to appear. You can either have lots of subclassed uiviews, each with their own drawRect, or a switch case statement inside a drawRect that selects what to draw based on some sort of type-of-subview property.
You might also want to set your sprite's view's background color to transparent, so that they are invisible until you draw into them.