[cocos2d-x-win32] Solution of using the keyboard to simulate accelerometer

supersuraccoon

Active member
Apr 25, 2011
27
2
0
www.supersuraccoon.byethost7.com
This post is a continue of this one:cocos2d-x-Win32_Install_Deploy_Tutorial

It is easy to use the cocos2d-win32+VS2008 to write some codes to learn the cocos2d
but the current dose not support the keyboard input response so that we can not
use the keyboard to simulate the accelermetor.

The whole cocos2d-win32 framework is base on win32 so I tried to make some modification
to the soruce code to make the cclayer response to the keyboard in order to simulate the
accelermetor(like moveing the sprites).

And I finally made it work so I'd like to share it here.

The main point is to redirect the keyboard messages to the taget CCLayer.

Important:
1.The sample codes and tutorial uses the version:cocos2d-0.99.4-x-0.7.1
2.The latest is cocos2d-0.99.5-x-0.8.2, there's been some modification here so we need to do some changes correspondingly:

1)The CCLayer.cpp file has been rename as CCLayer_mobile.cpp
2)In the CCXEGLView_win32.h,do not add the "include "CClayer"", just make a pre-declare: "class CCLayer;"
(or you'll get lots of errors, but I do not know the reseaon yet)
3)Add the include "CClayer" in the CCXEGLView_win32.cpp file

About solution:
1.It just make the CCLayer able to response to the keyboard input, there's not granty the solution is safe and sound
(like the use of the pointer or global stuff), the goal is just to "make it work".
2.The whole solution with images are in the attachment.

Abou Attchment:
1.cocos2d-x-win32_Use_keyboard_to_simulate_accelerometer.xls, the tutorial
2.KeyResponserDemo.rar, Multi CClayers response to the keyboard input
3.DoodleDrop_win32.rar, DoodleDrop win32 version,use keyboard to simulate accelermeter
4.DoodleDrop_iPhone.rar, DoodleDrop iphone version,just for comparison with win32 version
5.The sample project souce dose not contain the cocos2dx foler(it's way too big)

If you have any question or advice feel free to contact me ^_^

You can download all the attachments from the post in my site:
[cocos2d-x-win32] Solution of using the keyboard to simulate accelerometer | SuperSuRaccoon's World
 

Latest posts

Trending Posts

Members online

Forum statistics

Threads
260,349
Messages
1,766,511
Members
441,239
Latest member
FallDesigner