• 大小: 23.7MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-23
  • 语言: Java
  • 标签: android  

资源简介

✈️《沙漠风暴》是一款基于Android开发的纵版飞行射击游戏,以雷电(Shooting Game)为原型,参考微信打飞机大战,通过自定义的SurfaceView来实现游戏,游戏画面、音乐、战斗特效都不错

资源截图

代码片段和文件信息

package com.hurteng.stormplane;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.hurteng.stormplane.constant.ConstantUtil;
import com.hurteng.stormplane.constant.DebugConstant;
import com.hurteng.stormplane.sounds.GameSoundPool;
import com.hurteng.stormplane.view.EndView;
import com.hurteng.stormplane.view.MainView;
import com.hurteng.stormplane.view.ReadyView;

public class MainActivity extends Activity {
    private EndView endView;
    private MainView mainView;
    private ReadyView readyView;
    private GameSoundPool sounds;

    @SuppressLint(“HandlerLeak“)
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == ConstantUtil.TO_MAIN_VIEW) {
                toMainView();
            } else if (msg.what == ConstantUtil.TO_END_VIEW) {
                toEndView(msg.arg1);
            } else if (msg.what == ConstantUtil.END_GAME) {
                endGame();
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_title);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        sounds = new GameSoundPool(this);
        sounds.initGameSound();

        readyView = new ReadyView(this sounds);
        setContentView(readyView);

    }

    /**
     * 进入游戏界面
     */
    public void toMainView() {
        if (mainView == null) {
            mainView = new MainView(this sounds);
        }
        setContentView(mainView);
        readyView = null;
        endView = null;
    }

    /**
     * 进入结束分数统计界面
     *
     * @param score
     */
    public void toEndView(int score) {
        if (endView == null) {
            endView = new EndView(this sounds);
            endView.setScore(score);
        }
        setContentView(endView);
        mainView = null;
    }

    /**
     * 结束游戏
     */
    public void endGame() {
        if (readyView != null) {
            readyView.setThreadFlag(false);
        } else if (mainView != null) {
            mainView.setThreadFlag(false);
        } else if (endView != null) {
            endView.setThreadFlag(false);
        }
        this.finish();
    }

    public Handler getHandler() {
        return handler;
    }

    public void setHandler(Handler handler) {
        this.handler = handler;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }


    /**
     * 双击退出函数
     */
    private long firstTime = 0;

    @Override
    public boolean onkeydown(int keyCode KeyEvent event) {
        if (DebugConstant.DOUBLECLICK_EXIT) {
       

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-16 06:53  StormPlane-master\
     文件         760  2018-04-16 06:53  StormPlane-master\.gitignore
     目录           0  2018-04-16 06:53  StormPlane-master\.idea\
     文件         686  2018-04-16 06:53  StormPlane-master\.idea\compiler.xml
     目录           0  2018-04-16 06:53  StormPlane-master\.idea\copyright\
     文件          74  2018-04-16 06:53  StormPlane-master\.idea\copyright\profiles_settings.xml
     文件        4167  2018-04-16 06:53  StormPlane-master\.idea\markdown-navigator.xml
     目录           0  2018-04-16 06:53  StormPlane-master\.idea\markdown-navigator\
     文件         104  2018-04-16 06:53  StormPlane-master\.idea\markdown-navigator\profiles_settings.xml
     文件        2064  2018-04-16 06:53  StormPlane-master\.idea\misc.xml
     文件         369  2018-04-16 06:53  StormPlane-master\.idea\modules.xml
     文件         180  2018-04-16 06:53  StormPlane-master\.idea\vcs.xml
     文件       11357  2018-04-16 06:53  StormPlane-master\LICENSE
     文件        8710  2018-04-16 06:53  StormPlane-master\README.md
     目录           0  2018-04-16 06:53  StormPlane-master\app\
     文件         526  2018-04-16 06:53  StormPlane-master\app\build.gradle
     文件        2396  2018-04-16 06:53  StormPlane-master\app\proguard-android.txt
     文件         782  2018-04-16 06:53  StormPlane-master\app\proguard-project.txt
     目录           0  2018-04-16 06:53  StormPlane-master\app\release\
     文件     2296339  2018-04-16 06:53  StormPlane-master\app\release\app-release.apk
     文件         194  2018-04-16 06:53  StormPlane-master\app\release\output.json
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\main\
     文件         867  2018-04-16 06:53  StormPlane-master\app\src\main\AndroidManifest.xml
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\main\java\
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\main\java\com\
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\main\java\com\hurteng\
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\main\java\com\hurteng\stormplane\
     文件        3600  2018-04-16 06:53  StormPlane-master\app\src\main\java\com\hurteng\stormplane\MainActivity.java
     目录           0  2018-04-16 06:53  StormPlane-master\app\src\main\java\com\hurteng\stormplane\bullet\
     文件        1616  2018-04-16 06:53  StormPlane-master\app\src\main\java\com\hurteng\stormplane\bullet\BigPlaneBullet.java
............此处省略153个文件信息

评论

共有 条评论