This shows you the differences between two versions of the page.
— | manual_v1:dynamic_textures [2013/03/05 10:19] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Dynamic Textures ====== | ||
+ | Sparrow lets you create custom textures directly at run-time. However, we didn’t reinvent the wheel for that feature --- credit goes to the iPhone SDK, which already contains a powerful API called "Core Graphics" | ||
+ | |||
+ | You access the drawing API with a special init-method of SPTexture, which takes a " | ||
+ | |||
+ | Here's a sample of how to create a custom texture with Core Graphics in Sparrow: | ||
+ | |||
+ | <code objc> | ||
+ | SPTexture *customTexture = [[SPTexture alloc] initWithWidth: | ||
+ | draw: | ||
+ | { | ||
+ | // draw a string | ||
+ | CGContextSetGrayFillColor(context, | ||
+ | NSString *string = @" | ||
+ | [string drawAtPoint: | ||
+ | | ||
+ | }]; | ||
+ | </ | ||
+ | |||
+ | The thing starting with the caret (^) is the block. Place your drawing code in the block and it will appear on your texture later. | ||
+ | |||
+ | If you haven’t worked with Core Graphics before, there are numerous resources on the web that describe how to use them. [[http:// | ||
+ | |||
+ | ----- | ||
+ | |||
+ | //Next section: [[Compiled Sprites]]// |