我目前正在研究 cocos2d-android 项目,其中精灵之间的交互是使用“场景”完成的,没有使用 xml 文件,所以现在要做一些其他任务,我在按钮的 onTouch 上使用 xml 布局文件。下面是替换按钮 onTouch 上的场景的代码,因为没有使用场景,我应该在这里使用什么逻辑?我搜索了很多,找不到解决方案。请帮我。
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);
}
};