2

私は現在、「シーン」を使用してスプライト間の相互作用が行われる 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);
        }
    };
4

2 に答える 2

0

私はあなたと同じ意図を持っているので、あなたは間違った方向に進んだと思いますが、一連の調査の結果、Android 用の cocos2d-x API は、Android デバイス上で適切に動作するためのラッパーにすぎないことがわかりました。主な開発言語は、移植性のために依然としてC++です

于 2013-07-12T14:32:42.397 に答える