Skip to content

Instantly share code, notes, and snippets.

View sdabet's full-sized avatar

Sébastien Dabet sdabet

  • Grenoble, France
View GitHub Profile
@sdabet
sdabet / AppDelegate.m
Last active December 18, 2015 03:39
Handle Android back button in cocos2d-iphone with Apportable (in MyNavigationController class)
#ifdef APPORTABLE
- (BOOL) canBecomeFirstResponder
{
return YES;
}
- (void)buttonUpWithEvent:(UIEvent *)event
{
switch (event.buttonCode)
@sdabet
sdabet / gist:5719641
Last active December 18, 2015 03:39
Do not import TestFlight header if compiling with Apportable
#ifndef ANDROID
// Only on iOS
#import "TestFlight.h"
#endif
@sdabet
sdabet / gist:5719631
Created June 6, 2013 06:05
Enable true_color in Apportable to fix blending issue
"config": {
...
"FEATURES": ["opengles2","landscape","true_color"],
...
}
@sdabet
sdabet / gist:5703921
Created June 4, 2013 06:11
Layout issue in Apportable
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef ANDROID
[UIScreen mainScreen].currentMode = [UIScreenMode emulatedMode:UIScreenBestEmulatedMode];
#endif
...
}
@sdabet
sdabet / gist:5700411
Last active December 18, 2015 00:59
cocos2d shader modified for Apportable
" \n\
#ifdef GL_ES \n\
varying mediump vec4 v_color; \n\
varying mediump vec2 v_texcoord; \n\
#else \n\
varying vec4 v_color; \n\
varying vec2 v_texcoord; \n\
#endif \n\
\n\
void main() \n\
" \n\
#extension GL_OES_standard_derivatives : enable \n\
\n\
#ifdef GL_ES \n\
varying mediump vec4 v_color; \n\
varying mediump vec2 v_texcoord; \n\
#else \n\
varying vec4 v_color; \n\
varying vec2 v_texcoord; \n\
#endif \n\
@sdabet
sdabet / gist:5494321
Created May 1, 2013 08:27
Helper coordinates for multi-resolution support in cocos2d-x
visibleSize = director.getVisibleSize();
visibleOrigin = director.getVisibleOrigin();
LEFT_CENTER = cc.p(visibleOrigin.x, visibleOrigin.y+visibleSize.height/2);
RIGHT_CENTER = cc.p(visibleOrigin.x+visibleSize.width, visibleOrigin.y+visibleSize.height/2);
TOP_CENTER = cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height);
BOTTOM_CENTER = cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y);
CENTER = cc.p(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2);
LEFT_TOP = cc.p(visibleOrigin.x, visibleOrigin.y+visibleSize.height);
RIGHT_TOP = cc.p(visibleOrigin.x+visibleSize.width, visibleOrigin.y+visibleSize.height);
@sdabet
sdabet / gist:5481015
Last active December 16, 2015 18:50
Load resources generated by CocosBuilder from cocos2d-x cross-platform app
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
CCSize designSize = CCSizeMake(480, 320);
CCSize resourceSize = CCSizeMake(480, 320);
CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();
@sdabet
sdabet / gist:5227325
Created March 23, 2013 11:10
touchSwallow property in CCLayer
-(id) init {
if(self = [super init]) {
self.touchMode = kCCTouchesOneByOne;
self.touchSwallow = NO;
self.touchEnabled = YES;
}
return self;
}
@sdabet
sdabet / gist:5227318
Last active December 15, 2015 07:59
Override registerWithTouchDispatcher to disable touch swallowing
-(id) init {
if(self = [super init]) {
self.touchEnabled = YES;
}
return self;
}
/* Need to override because we don't want to swallow touches */
-(void) registerWithTouchDispatcher {
[[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:NO];