SneakyInput

虚拟控制手柄
因为iOS设备使用触摸屏来输入,没有传统移动游戏设备配备的按钮,十字按钮
或者模拟手柄,我们需要一个虚拟手柄来控制游戏。

SneakyInput是一个不错选择。源代码托管在http://github.com/sneakyness/SneakyInput


问题:
Hello there, i have created a project using cocos2d iOS with Box2d templet in new cocos2d v2.x. Later added the SneakyInput control. When i build it get some errors in ColoredCircleSprite Class.

Error logs:
Use of undeclared identifier 'GL_COLOR_ARRAY'
Use of undeclared identifier 'GL_TEXTURE_COORD_ARRAY'

解决办法:
http://www.cocos2d-iphone.org/forum/topic/31928

Cocos2d v2.0. does not use some of the code in SneakyJoystick. You should do the following:

Comment out these lines in the Draw function in both ColoredCircleSprite.m and ColoredSquareSprite.m:
At the TOP of the function, comment these lines:
//glDisableClientState(GL_TEXTURE_COORD_ARRAY);
//glDisableClientState(GL_COLOR_ARRAY);
//glDisable(GL_TEXTURE_2D);
//glVertexPointer(2, GL_FLOAT, 0, circleVertices_);
//glColor4f(color_.r/255.0f, color_.g/255.0f, color_.b/255.0f, opacity_/255.0f);

At the BOTTOM of the function, comment these lines:
// restore default GL state
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//glEnableClientState(GL_COLOR_ARRAY);
//glEnable(GL_TEXTURE_2D);

At the TOP of the function, add this line:
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color );

You can read more about this and other changes in Cocos2d v 2.0. at:
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:migrate_to_v2.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值