This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
users:shilo:extensions:shthumbstick [2013/09/10 05:28] – [Data entry] shilo | users:shilo:extensions:shthumbstick [2013/09/10 05:28] (current) – [Sample] shilo | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SHThumbstick ====== | ||
+ | ---- dataentry extension ---- | ||
+ | type : extension | ||
+ | author_mail | ||
+ | description | ||
+ | lastupdate_dt | ||
+ | compatible | ||
+ | depends | ||
+ | tags : thumbstick, joystick, joypad, dpad, controller | ||
+ | homepage_url | ||
+ | download_url | ||
+ | demo (old)_url | ||
+ | basic sample (old)_url : http:// | ||
+ | ---- | ||
+ | |||
+ | ===== Description ===== | ||
+ | SHThumbstick class will allow you to create multiple thumbsticks to a game with ease. You can choose to use images or go without images. You can change the thumbstick type to static, relative, absolute, float. More details about these types are in the sample project. There' | ||
+ | |||
+ | ===== Sample ===== | ||
+ | [[http:// | ||
+ | * Project: [[http:// | ||
+ | * Screenshot: [[http:// | ||
+ | * Recording: [[http:// | ||
+ | |||
+ | ===== Examples ===== | ||
+ | ==== Initialization Example ===== | ||
+ | <code objc> | ||
+ | // | ||
+ | SHThumbstick *absoluteThumbstick = [SHThumbstick thumbstick]; | ||
+ | |||
+ | //set the inner image | ||
+ | absoluteThumbstick.innerImage = [SPImage imageWithContentsOfFile: | ||
+ | |||
+ | //set the outer image | ||
+ | absoluteThumbstick.outerImage = [SPImage imageWithContentsOfFile: | ||
+ | |||
+ | //change the thumbstick type to absolute, which will only appear on touch | ||
+ | absoluteThumbstick.type = SHThumbstickAbsolute; | ||
+ | |||
+ | //set the bounds for landscape | ||
+ | absoluteThumbstick.bounds = [SPRectangle rectangleWithX: | ||
+ | |||
+ | //change the inner radius to 0 | ||
+ | absoluteThumbstick.innerRadius = 0; | ||
+ | |||
+ | //change the outer radius to 40 | ||
+ | absoluteThumbstick.outerRadius = 40; | ||
+ | |||
+ | //draw the values of innerRadius, | ||
+ | absoluteThumbstick.debugDraw = YES; | ||
+ | |||
+ | //add an event listener to get the event.distance and event.direction | ||
+ | [self addEventListener: | ||
+ | |||
+ | //add the thumbstick to the stage | ||
+ | [self addChild: | ||
+ | </ | ||
+ | |||
+ | ==== Event Example ==== | ||
+ | <code objc> | ||
+ | - (id)initWithWidth: | ||
+ | if (self = [super initWithWidth: | ||
+ | SHThumbstick *thumbstick = [SHThumbstick thumbstick]; | ||
+ | thumbstick.innerImage = [SPImage imageWithContentsOfFile: | ||
+ | thumbstick.outerImage = [SPImage imageWithContentsOfFile: | ||
+ | thumbstick.debugDraw = YES; | ||
+ | [self addChild: | ||
+ | |||
+ | [thumbstick addEventListener: | ||
+ | [thumbstick addEventListener: | ||
+ | [thumbstick addEventListener: | ||
+ | [thumbstick addEventListener: | ||
+ | } | ||
+ | return self; | ||
+ | } | ||
+ | |||
+ | - (void)onThumbstickTouch: | ||
+ | NSLog(@" | ||
+ | } | ||
+ | |||
+ | - (void)onThumbstickMove: | ||
+ | NSLog(@" | ||
+ | } | ||
+ | |||
+ | - (void)onThumbstickTouchUp: | ||
+ | NSLog(@" | ||
+ | } | ||
+ | |||
+ | - (void)onThumbstickChanged: | ||
+ | NSLog(@" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Instructions ===== | ||
+ | ==== To add into your Sparrow project ==== | ||
+ | - Download the source files here: [[https:// | ||
+ | - Open your desired Sparrow project | ||
+ | - Drag and drop the files into the " | ||
+ | - Open " | ||
+ | - Include the extension: <code objc># | ||
+ | - Save " | ||
+ | |||
+ | ==== To add directly into Sparrow source ==== | ||
+ | - Download the source files here: [[https:// | ||
+ | - Save the files into Sparrow' | ||
+ | * Example: "/ | ||
+ | - Navigate back one directory and open " | ||
+ | * Example: "/ | ||
+ | - Inside the " | ||
+ | * Example: " | ||
+ | - Right click the " | ||
+ | - Navigate into the "/ | ||
+ | - On the next window, leave all options as default and click " | ||
+ | - In the " | ||
+ | * Example " | ||
+ | - At the bottom of the file, add: <code objc># | ||
+ | - Save " | ||
+ | - Close " | ||
+ | |||
+ | ===== Source Code ===== | ||
+ | %gist(878049)% | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | * // | ||
+ | |||
+ | ===== Todo ===== | ||
+ | * (EMPTY) |