Mattcn's Blog

mattcn.com

最近在做cocos2d -> 2d-x的代码移植, 在动画Action的显示过程中, iPad2的测试出现了闪屏的现象,经过google得到如下解决方案:
在Delegate初始化的时候 将Projection设置为2D并且关闭DepthTest.

CCDirector::sharedDirector()->setProjection(CCDirectorProjection2D);
CCDirector::sharedDirector()->setDepthTest(false);

More

In IOS development, normally we use

[UIDevice currentDevice]

or

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {// todo}

to check the current resolution and do the custom stuffs. However, in cocos2d-x cross platform environment, I prefer to use the template below to custom UI positions or physics vars in different types of resolutions.

    if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) {
    // IOS Resolution:
        if( (CCDirector::sharedDirector()->getWinSize().height > kDeviceIPhoneHeight ) &&
           (CCDirector::sharedDirector()->getWinSize().width > kDeviceIPhoneWidth )) {
            // iPad Resolution implement here:
        }
        else {
            // iPhone Resolution implements here:
        }
    }
    else if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID){
    // Android:

    }

else {

// iPhone Resolution implements here:

}

}

else if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID){

// Android:

}

this template may needs to update when iPad2-HD/iPad3 coming out.

Note:
1. 打开GameConfig.h文件, 定义Autorotation类型, kGameAutorotationUIViewController by default:

#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationUIViewController
/*
#define kGameAutorotationNone 0
#define kGameAutorotationCCDirector 1
#define kGameAutorotationUIViewController 2
/*

2.在RootViewController里,找到如下方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

根据Config里定义的类型,选择屏幕适应性: 源代码里都有很好的范例:

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight )
return YES;

// Unsupported orientations:
// UIInterfaceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown
return NO;

例如只想显示Portrait:

if( interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;

十一月 28th, 2011

SNV资源

No Comments, 技术文摘, by mattcn.

今天开始起航第一个iPhone应用,做一个千军破的游戏应用练手。

在网上google了一些免费的SVN服务器. 存档备用:

1. Assembla

2. Beanstalk.

3. Unfuddle

4.bitbucket.org

5.XP-Dev.

” It looks kind of nice and a good alternative to Assembla, now that it makes your code public if you don’t pay.”

6.ProjectLocker

“ProjectLocker has free Subversion hosting, with unlimited repositories and a 300 MB quota. You can also use Git if you prefer, and all repositories come with Trac.”

测试平台,Test Flight..强大的测试平台.

1. The Black Art of 3D Game Programming Chapter 10 While this isn’t an OpenGL ES resource it is a great introduction to the 2D and 3D math involved in using OpenGL ES.  I  mention it first because if you don’t understand this stuff you’ll have a hell of a time coding OpenGL ES, and this is a great  introduction.  The whole book can be found here for free.  It is an old book, but the math still holds true.

More

最近忙着给璐申请伦敦的Master, 因为我在伦敦工作, 基本她的目标学校也确定在了伦敦周边. 考虑了璐的专业情况,参考了排名,浏览了学校的主页,以及听取了英国当地朋友与公司Designer意见,逐渐的把目标缩小到了如下学校,资料很详细,目前已经拿了2个学校的offer。 发出来共享,希望能够给正在申请同类院校的同学一些帮助。

More

五月 2nd, 2011

One-nil to the Arsenal!!

No Comments, Gunner, by mattcn.

1st May, Arsenal vs Machester United. 这是一场心仪已久的比赛,这也是去阿森纳主场看的第一场比赛。订票的时候激动万分,我们与榜首曼X的差距还不是很大,这场比赛也将会成为争冠的一场焦点比赛。 然而随着阿森纳现象的继续发作,我们在下班赛季的疲软和种种短路让这场比赛的结果与冠军的归属毫无瓜葛。

More

四月 30th, 2011

密码保护:致睡美人

要查看留言请输入您的密码。, Love, by mattcn.

这是一篇受密码保护的文章。您需要提供访问密码:


四月 10th, 2011

念念不忘 4.9

No Comments, 生活随笔, by mattcn.

今天是实习后的第二个周末,一个大懒觉直奔正午的阳光。 显然如果继续执迷,就会错过一场盛宴。”快起来,快起来, 快从枕头里抬起头来!” 沐浴更衣:P,和室友们向Tate Modern出发。

初来伦敦,还没有好好停下脚步驻足欣赏,就开始了忙碌工作,感受着快节奏与高效率,早8点晚8点的奔波于办公室与宿舍之间。这样一个难的的周末对我也是非常宝贵的。室友们都是学服装设计的,每个人都有自己对艺术的独到眼光。 和他们一同去Tate自然会有很多收获,而这次的收获,却让我意想不到。

DSC01609 More

二月 5th, 2011

无间道St. James Park

No Comments, Gunner, by mattcn.

不得不说,我真是好运,见证了一次英超赛场上的奇迹。

不得不说,我真是倒霉,一场比赛从天堂掉落到了地狱。

More