Skip to content

Instantly share code, notes, and snippets.

@kazukitanaka0611
kazukitanaka0611 / SpriteKit Pazzle and Dragon clone
Created June 24, 2014 09:19
SpriteKit Pazzle and Dragon clone
#import <SpriteKit/SpriteKit.h>
typedef NS_ENUM(NSInteger, BallType)
{
Blue,
Red,
Green,
Yellow,
Purple,
Pink,
@kazukitanaka0611
kazukitanaka0611 / drawRect radias view
Created July 10, 2014 09:14
drawRect radias view
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef path = createRoundeRectForRect(self.bounds, 15.0);
CGContextSaveGState(context);
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
Edge* MakeEdge(NSUInteger i, NSUInteger j);
@interface Edge : NSObject <NSCopying>
@property (nonatomic, assign, readonly) NSUInteger i;
@property (nonatomic, assign, readonly) NSUInteger j;
+ (instancetype)edgeWithI:(NSUInteger)i J:(NSUInteger)j;
@end
static CGFloat const SideHelperView = 2.0;
static CGFloat const AnimationDuration = .5;
struct Animation {
NSTimeInterval sideDelay;
NSTimeInterval sideDumping;
NSTimeInterval sideVelocity;
NSTimeInterval centerDelay;
NSTimeInterval centerDumping;
@kazukitanaka0611
kazukitanaka0611 / My method NSURLSession blocks
Created July 31, 2014 06:34
My method NSURLSession blocks
- (void)getRequestData:(NSString *)urlString
success:(void(^)(NSArray *jsonList))success
failure:(void(^)(NSError *error))failure
{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSURLSessionDataTask *task = [session dataTaskWithURL:
[NSURL URLWithString:urlString]
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
#include "DotSprite.h"
class HelloWorld : public cocos2d::Layer
{
public:
@kazukitanaka0611
kazukitanaka0611 / Swift sort method
Created January 27, 2015 20:51
This sample Swift sort method key is enum:Int
var keys = Array(buttons.keys)
sort(&keys){$0.rawValue < $1.rawValue}
@kazukitanaka0611
kazukitanaka0611 / AutoLayout Code
Created February 5, 2015 07:43
AutoLayout Code
let myView = UIView()
myView.setTranslatesAutoresizingMaskIntoConstraints(false)
myView.backgroundColor = UIColor.greenColor()
self.view.addSubview(myView)
self.view.addConstraints([
NSLayoutConstraint(item: myView,
attribute: .Width,
relatedBy: .Equal,
toItem: self.view,
@kazukitanaka0611
kazukitanaka0611 / AutoLayout code view in view
Created February 6, 2015 03:49
AutoLayout code view in view
let myView1 = UIView()
myView1.backgroundColor = UIColor.greenColor()
myView1.setTranslatesAutoresizingMaskIntoConstraints(false)
self.view.addSubview(myView1)
let myView2 = UIView()
myView2.backgroundColor = UIColor.orangeColor()
myView2.setTranslatesAutoresizingMaskIntoConstraints(false)
myView1.addSubview(myView2)
@kazukitanaka0611
kazukitanaka0611 / AutoLayout code button margine
Created February 6, 2015 05:38
AutoLayout code button margine
self.textView.becomeFirstResponder()
let baseView = UIView()
baseView.setTranslatesAutoresizingMaskIntoConstraints(false)
baseView.backgroundColor = UIColor.orangeColor()
self.textView.inputView = baseView
NSLog("frame wisth%f, height", baseView.frame.size.width, baseView.frame.size.height)