Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
users:shilo:extensions:shcircle [2011/11/10 01:02]
shilo [Data entry]
users:shilo:extensions:shcircle [2013/03/05 10:19] (current)
Line 1: Line 1:
 +====== SHCircle ======
 +---- dataentry extension ----
 +type          : extension
 +author_mail ​  : shilo86@gmail.com Shilo White
 +description ​  : A simple customizable circle.
 +lastupdate_dt : 2011-03-14
 +compatible ​   : v1.X
 +depends ​      : ​
 +tags          : circle, primitive
 +homepage_url ​ : https://​gist.github.com/​870359
 +download_url ​ : https://​gist.github.com/​gists/​870359/​download
 +sample_url ​   : http://​shilo.coarsemode.com/​sparrow/​extensions/​shcircle/​PacmanSample.zip
 +----
  
 +===== Description =====
 +SHCircle class will allow you to create primitive circles on the stage. You can customize inner color, outer color, border color, change the border width, toggle the fill and border, set the center x, center y, change the radius x, radius y, set the degrees to render, rotate around center, and everything else you can do with an SPDisplayObject.
 +
 +===== Sample =====
 +[[http://​shilo.coarsemode.com/​sparrow/​extensions/​shcircle/​PacmanSample.zip|{{http://​shilo.coarsemode.com/​sparrow/​extensions/​shcircle/​PacmanScreenshot.png}}]]
 +  * Project: [[http://​shilo.coarsemode.com/​sparrow/​extensions/​shcircle/​PacmanSample.zip|Pacman]]
 +  * Screenshot: [[http://​shilo.coarsemode.com/​sparrow/​extensions/​shcircle/​PacmanScreenshot.png|PacmanScreenshot.png]]
 +  * Recording: [[http://​shilo.coarsemode.com/​sparrow/​extensions/​shcircle/​PacmanRecording.mov|PacmanRecording.mov]]
 +
 +===== Example =====
 +<code objc>
 +//​initialize a circle with width of 100 and height of 100
 +SHCircle *circle = [SHCircle circleWithWidth:​100 height:​100];​
 + 
 +//set the x radius to 25, which changes the width to 50
 +circle.radiusX = 25.0f;
 +
 +//set the y radius to 10, which changes the height to 20
 +circle.radiusY = 10.0f;
 + 
 +//render half of the circle
 +circle.degrees = 180;
 + 
 +//rotate the circle 45 degrees around the center
 +circle.centerRotation = 45;
 + 
 +//change the solid color to blue
 +circle.color = 0x0000ff;
 + 
 +//change the inner color to red and outer color to black
 +circle.innerColor = 0xff0000;
 +circle.outerColor = 0x000000;
 + 
 +//toggle the border on
 +circle.border = YES;
 + 
 +//set the border width to 1 pixel
 +circle.borderWidth = 1.0f;
 + 
 +//set the border color to red
 +circle.borderColor = 0xff0000;
 + 
 +//toggle the fill off
 +circle.fill = NO;
 + 
 +//center the circle on stage
 +circle.centerX = 320/2;
 +circle.centerY = 480/2;
 + 
 +//add the circle to stage
 +[self addChild:​circle];​
 +</​code>​
 +===== Instructions =====
 +==== To add into your Sparrow project ====
 +  - Download the source files here: [[https://​gist.github.com/​gists/​870359/​download]]
 +  - Open your desired Sparrow project
 +  - Drag and drop the files into the "​Groups & Files" pane
 +  - Open "​Game.h"​
 +  - Include the extension: <code objc>#​include "​SHCircle.h"</​code>​
 +  - Save "​Game.h"​
 +
 +==== To add directly into Sparrow source ====
 +  - Download the source files here: [[https://​gist.github.com/​gists/​870359/​download]]
 +  - Save the files into Sparrow'​s "/​Classes/"​ directory
 +    * Example: "/​sparrow/​src/​Classes/"​
 +  - Navigate back one directory and open "​Sparrow.xcodeproj"​
 +    * Example: "/​sparrow/​src/​Sparrow.xcodeproj"​
 +  - Inside the "​Groups & Files" pane, locate the "​Display"​ group folder
 +    * Example: "​Sparrow -> Classes -> Display"​
 +  - Right click the "​Display"​ group folder and click "Add -> Existing Files.."​
 +  - Navigate into the "/​Classes/"​ directory and select "​SHCircle.h"​ and "​SHCircle.m",​ then click "​add"​
 +  - On the next window, leave all options as default and click "​add"​
 +  - In the "​Groups & Files" pane, Open "​Sparrow.h"​
 +    * Example "​Sparrow -> Classes -> Sparrow.h"​
 +  - At the bottom of the file, add: <code objc>#​import "​SHCircle.h"</​code>​
 +  - Save "​Sparrow.h"​
 +  - Close "​Sparrow.xcodeproj"​
 +
 +===== Source Code =====
 +%gist(870359)%
 +
 +===== Changelog =====
 +  * //​2011-01-27://​ First version
 +
 +===== Todo =====
 +  * Add anti-aliasing
 +  * Use Core Graphics instead of OpenGL ES
 +  * Only capture touch inside the circle
  users/shilo/extensions/shcircle.txt · Last modified: 2013/03/05 10:19 (external edit)
 
Powered by DokuWiki