如何在cocos2d android中使用活动?
我目前正在从事cocos2dandroid项目,其中sprite之间的交互是使用“场景”完成的,我没有使用xml文件,所以现在要做一些其他任务,我使用按钮上的xml布局文件。 下面是替换按钮onTouch上的场景的代码,因为没有使用场景,我应该在这里使用什么逻辑?我找了很多,找不到答案。请帮帮我如何在cocos2d android中使用活动?,android,cocos2d-iphone,cocos2d-x,cocos2d-android,Android,Cocos2d Iphone,Cocos2d X,Cocos2d Android,我目前正在从事cocos2dandroid项目,其中sprite之间的交互是使用“场景”完成的,我没有使用xml文件,所以现在要做一些其他任务,我使用按钮上的xml布局文件。 下面是替换按钮onTouch上的场景的代码,因为没有使用场景,我应该在这里使用什么逻辑?我找了很多,找不到答案。请帮帮我 public void callbackGameLayer(Object sender) { //Global.playSoundEffect(R.raw.button); CCScen
public void callbackGameLayer(Object sender) {
//Global.playSoundEffect(R.raw.button);
CCScene scene = CCScene.node();
scene.addChild(new GameLayer(), -1);
CCDirector.sharedDirector().replaceScene(scene);
}
这是流必须进行的活动
public class IntermediateMain extends Activity {
protected CCGLSurfaceView mGlSurfaceView;
private static int MAX_GAME_TIME_SECONDS = 300;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
// get full screen setup and keep screen bright and on when the window
// is visible
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mGlSurfaceView = new CCGLSurfaceView(this);
setContentView(R.layout.main);
final Button newGame = (Button) findViewById(R.id.start_game_btn);
final TextView numSecondsTextView = (TextView) findViewById(R.id.num_seconds_text_view);
final TextView numSacksTextView = (TextView) findViewById(R.id.num_sacks_text_view);
OnSeekBarChangeListener changeListener = new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
int currentGameTimeInSeconds = (progress * MAX_GAME_TIME_SECONDS) / 100;
numSecondsTextView.setText(Integer
.toString(currentGameTimeInSeconds));
numSacksTextView.setText(Integer.toString(IntermediateGameLayer
.numSacksInGame(currentGameTimeInSeconds)));
newGame.setEnabled(currentGameTimeInSeconds > 0);
}
};
我认为你走错了方向,因为我有着和你以前相同的意图,但是经过一系列的研究,我发现:Android的COCOS2D-XAPI只是在Android设备上正常工作的包装器。主要的开发语言仍然是C++的可移植性,
< P>切换到Android中的另一个活动,您需要使用JNI代码将调用从cocos2d-x(c++)发送到当前的android活动。然后在那里开始一项新的活动。当您切换到其他活动时,cocos2d-x游戏将暂停。当您尝试运行此演示时,发生了什么事。?我在这一行场景中遇到错误。addChild(新游戏层(),-1);,这是由于@AMhmm类中缺少“extends CCLayer”。。我也试着从一个场景打电话到另一个活动,但不允许这样做。。只有我们能在CCLayer上工作。。如果有什么事我会解决的。我会通知你的