Basic android Game Design Space Ship Game - part 2 (Game Activity)
 

package com.chitraksh.chigamebasicbuilding;

import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.app.Activity;
import android.graphics.Point;

public class GameActivity extends Activity {
    GameView gameView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Display display = getWindowManager().getDefaultDisplay();
        // Load the resolution into a Point object
        Point size = new Point();
        display.getSize(size);
        FrameLayout gameframeLayout=new FrameLayout(this);
        gameView=new GameView(this,size.x, size.y);
        LinearLayout gameWidetslinearLayout=new LinearLayout(this);
        Button fireButton =new Button(this);
        fireButton.setText("Fire");
        fireButton.setWidth(150);
        fireButton.setHeight(100);
        fireButton.setX(600);
        fireButton.setY(400);
        fireButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                gameView.fireBullet();
            }
        });
        gameWidetslinearLayout.addView(fireButton);
        
        gameframeLayout.addView(gameView);
        gameframeLayout.addView(gameWidetslinearLayout);
        
        setContentView(gameframeLayout);
        
    }
    @Override
    protected void onPause() {
        super.onPause();
        gameView.pause();
    }
    @Override
    protected void onResume() {
        super.onResume();
        gameView.resume();
    }

}

share on whatapp
194 Views

Comments

106.215.151.238Nice one!
 
 
Private Policy   Terms of Service   4922