Skip to content

Instantly share code, notes, and snippets.

#define CCB_LOAD_SCENE(T) \
[]()->cocos2d::Scene *{ \
auto nodeLoaderLibrary = cocosbuilder::NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); \
nodeLoaderLibrary->registerNodeLoader(#T, T ## Loader::loader()); \
auto ccbReader = new cocosbuilder::CCBReader(nodeLoaderLibrary); \
auto layer = ccbReader->readNodeGraphFromFile(#T ".ccbi"); \
auto scene = cocos2d::Scene::create(); \
if (layer) { \
scene->addChild(layer); \
} \
CCNodeLoaderLibrary* nodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
nodeLoaderLibrary->registerCCNodeLoader("TestScene", TestSceneLoader::loader());
CCBReader* ccbReader = new CCBReader(nodeLoaderLibrary);
// ここで画像を保存したパスを指定する
ccbReader->setCCBRootPath(CCFileUtils::sharedFileUtils()->getWritablePath().c_str());
CCNode* node = ccbReader->readNodeGraphFromFile("TestScene.ccbi");
@gin0606
gin0606 / gist:8122264
Last active January 1, 2016 08:59
Cocos2d-xで画像のダウンロードと保存。保存した画像をCCSpriteで表示する
// HTTP通信
void ResourceDownloader::startDownload(char const *url) {
CCHttpRequest *request = new CCHttpRequest();
request->setUrl(url);
request->setRequestType(cocos2d::extension::CCHttpRequest::kHttpGet);
request->setResponseCallback(this, httpresponse_selector(ResourceDownloader::onHttpRequestCompleted));
CCHttpClient::getInstance()->send(request);
request->release();
@gin0606
gin0606 / KKMenuItem.cpp
Created December 25, 2013 04:28
CCMenuItemで長押しを検知する
//
// Created by gin0606 on 2013/12/25.
//
#include "KKMenuItem.h"
KKMenuItem::KKMenuItem() :
CCMenuItem(),
@gin0606
gin0606 / CCJson.cpp
Last active December 31, 2015 05:09
Cocos2d-xでJSONをCCDictionary/CCArrayに変換する
//
// Created by gin0606 on 2013/12/12.
//
#include "CCJson.h"
CCDictionary *CCJson::JSONObjectWithString(std::string jsonString) {
return CCJson::JSONObjectWithString(jsonString.c_str());
@gin0606
gin0606 / myXcode.icls
Created September 30, 2013 03:36
XcodeのMidnightをいじった奴をAppCodeでも同じような感じで設定したやつ
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="myXcode" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="0.99" />
<option name="EDITOR_FONT_SIZE" value="15" />
<option name="CONSOLE_FONT_NAME" value="Menlo" />
<option name="CONSOLE_LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_NAME" value="Ricty" />
<colors>
<option name="ADDED_LINES_COLOR" value="5f665f" />
<option name="CARET_COLOR" value="888888" />
@gin0606
gin0606 / gist:6051265
Last active December 20, 2015 01:48
TabBar選択するとModalView開くやつ
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1, *viewController2;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil];
viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil];
} else {
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPad" bundle:nil];
@gin0606
gin0606 / expand_url.py
Created June 15, 2013 16:58
引数に短縮URL渡すと展開したURL返す奴。HEAD Requestだから早い。
#!/usr/local/bin/python
# -*- coding: utf-8; -*-
from urlparse import urlparse
from httplib import HTTPConnection
def expandURL(url):
"""
短縮URLを展開する
Arguments:
- `url`: 展開したいURL
//
// Created by kkgn06 on 2013/05/29.
//
#import <Foundation/Foundation.h>
@interface NSDictionary (KKWithoutNSNull)
-(id)objectOrNilForKey:(id)key;
@end
//
// Created by gin0606 on 2013/05/10.
//
#import <Foundation/Foundation.h>
@interface NSMutableArray (NonRetainedObject)
- (void)addNonretainedObject:(id)anObject;
- (id)nonretainedObjectAtIndex:(NSUInteger)index;