Differences

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

Link to this comparison view

Both sides previous revision Previous revision
users:shilo:extensions:shpolygon [2013/03/05 10:19]
127.0.0.1 external edit
users:shilo:extensions:shpolygon [2013/08/30 15:50] (current)
shilo
Line 1: Line 1:
 +====== SHPolygon (OLD VERSION) ======
 +---- dataentry extension ----
 +type          : extension
 +author_mail ​  : shilo86@gmail.com Shilo White
 +description ​  : A simple customizable polygon.
 +lastupdate_dt : 2011-03-19
 +compatible ​   : v1.X
 +depends ​      : ​
 +tags          : polygon, shape, primitive
 +homepage_url ​ : https://​gist.github.com/​878014
 +download_url ​ : https://​gist.github.com/​gists/​878014/​download
 +sample_url ​   : http://​shilo.coarsemode.com/​sparrow/​extensions/​shpolygon/​StarFieldSample.zip
 +----
 +===== Description =====
 +SHPolygon class will allow you to create primitive polygon shapes on the stage. You can set the number of sides, 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, rotate around center, and everything else you can do with an SPDisplayObject.
  
 +===== Sample =====
 +[[http://​shilo.coarsemode.com/​sparrow/​extensions/​shpolygon/​StarFieldSample.zip|{{http://​shilo.coarsemode.com/​sparrow/​extensions/​shpolygon/​StarFieldScreenshot.png}}]]
 +  * Project: [[http://​shilo.coarsemode.com/​sparrow/​extensions/​shpolygon/​StarFieldSample.zip|Star Field]]
 +  * Screenshot: [[http://​shilo.coarsemode.com/​sparrow/​extensions/​shpolygon/​StarFieldScreenshot.png|StarFieldScreenshot.png]]
 +  * Recording: [[http://​shilo.coarsemode.com/​sparrow/​extensions/​shpolygon/​StarFieldRecording.mov|StarFieldRecording.mov]]
 +
 +===== Example =====
 +<code objc>
 +//add a triangle with default sides: 3
 +SHPolygon *triangle = [SHPolygon polygonWithWidth:​100 height:​100];​
 +[self addChild:​triangle];​
 + 
 +//add a diamond shape
 +SHPolygon *diamond = [SHPolygon polygonWithWidth:​320 height:​480];​
 +diamond.sides = 4;
 +[self addChild:​diamond];​
 + 
 +//add a star and center it on stage
 +SHPolygon *star = [SHPolygon polygonWithWidth:​320 height:​320];​
 +star.sides = 5;
 +star.innerColor = 0xffffff;
 +star.outerColor = 0x000000;
 +star.centerX = 320/2;
 +star.centerY = 480/2;
 +[self addChild:​star];​
 + 
 +//add a circle with default width and height: 32
 +SHPolygon *circle = [SHPolygon polygon];
 +circle.sides = 360;
 +[self addChild:​circle];​
 +</​code>​
 +
 +===== Instructions =====
 +==== To add into your Sparrow project ====
 +  - Download the source files here: [[https://​gist.github.com/​gists/​878014/​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 "​SHPolygon.h"</​code>​
 +  - Save "​Game.h"​
 +
 +==== To add directly into Sparrow source ====
 +  - Download the source files here: [[https://​gist.github.com/​gists/​878014/​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 "​SHPolygon.h"​ and "​SHPolygon.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 "​SHPolygon.h"</​code>​
 +  - Save "​Sparrow.h"​
 +  - Close "​Sparrow.xcodeproj"​
 +
 +===== Source Code =====
 +%gist(878014)%
 +
 +===== Changelog =====
 +  * //​2011-02-06://​ First version
 +  * //​2011-03-19://​ Fixed small bug
 +
 +===== Todo =====
 +  * Add anti-aliasing
 +  * Use Core Graphics instead of OpenGL ES
 +  * Only capture touch inside the polygon
  users/shilo/extensions/shpolygon.txt · Last modified: 2013/08/30 15:50 by shilo
 
Powered by DokuWiki