Skip to content

Instantly share code, notes, and snippets.

@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 / 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}
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
#include "DotSprite.h"
class HelloWorld : public cocos2d::Layer
{
public:
@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]
static CGFloat const SideHelperView = 2.0;
static CGFloat const AnimationDuration = .5;
struct Animation {
NSTimeInterval sideDelay;
NSTimeInterval sideDumping;
NSTimeInterval sideVelocity;
NSTimeInterval centerDelay;
NSTimeInterval centerDumping;
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
@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);
@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 / ClipingSprite
Last active August 29, 2015 13:57
ClipingSprite
void ClipSprite::visit()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCRect bounds = CCRectMake(0, 0, winSize.width, 100);
glEnable(GL_SCISSOR_TEST);
CCEGLView::sharedOpenGLView()->setScissorInPoints(bounds.getMinX(),
bounds.getMinY(),
bounds.size.width,
bounds.size.height);
@kazukitanaka0611
kazukitanaka0611 / vertical scroll for SpriteKit
Created February 13, 2014 05:24
vertical scroll for SpriteKit
#import "MyScene.h"
@interface MyScene()
@property (nonatomic, strong) SKSpriteNode *currentBackground;
@property (nonatomic, assign) CFTimeInterval lastUpdateTimeInterval;
@end
static NSString* const BACK_GROUND = @"background";