Androi游戏源码分享之2048.docVIP

  • 13
  • 0
  • 约1.81万字
  • 约 16页
  • 2017-06-12 发布于河南
  • 举报
Androi游戏源码分享之2048

Android游戏源码分享之2048 本文主要是给大家分享了安卓版的游戏2048的源码,以及制作思路,是篇非常不错的文章,有需要的朋友可以参考下 引言 程序猿们,是否还在为你的老板辛辛苦苦的打工而拿着微薄的薪水呢,还是不知道如何用自己的应用或游戏来赚钱呢! 在这里IQuick将教您如何同过自己的应用来赚取自己的第一桶金! 你是说自己的应用还没有做出来? 不,在這里已经为你提供好了一个完整的游戏应用了,在文章的下面有源码的地址哦。你只要稍做修改就可以变成一个完全属于自己的应用了,比如将4*4换成5*5,甚至是其它的。如果你实在是慵懒至极的话,你只要将本应用的包名及广告换成自己的,就可以上传到市场上轻轻松松赚取自己的第一桶金了。 如果你觉得本文很赞的话,就顶一下作者吧,从下面的安装地址中下载应用,或者在导入本工程运行的时候,从广告中安装一个应用。动一动你的手指,就能让作者更进一步,也能让作者以后更加有动力来分享吧。 安装 项目结构 重要代码解读MainView游戏的主体类 //初始化方法,里面初始化了一些常量,字体颜色等 name=code class=javapublic MainView(Context context) { super(context); Resources resources = context.getResources(); //Loading resources game = new MainGame(context, this); try { //Getting assets backgroundRectangle = resources.getDrawable(R.drawable.background_rectangle); lightUpRectangle = resources.getDrawable(R.drawable.light_up_rectangle); fadeRectangle = resources.getDrawable(R.drawable.fade_rectangle); TEXT_WHITE = resources.getColor(R.color.text_white); TEXT_BLACK = resources.getColor(R.color.text_black); TEXT_BROWN = resources.getColor(R.color.text_brown); this.setBackgroundColor(resources.getColor(R.color.background)); Typeface font = Typeface.createFromAsset(resources.getAssets(), ClearSans-Bold.ttf); paint.setTypeface(font); paint.setAntiAlias(true); } catch (Exception e) { System.out.println(Error getting assets?); } setOnTouchListener(new InputListener(this)); game.newGame(); } //游戏界面的绘制 @Override protected void onSizeChanged(int width, int height, int oldw, int oldh) { super.onSizeChanged(width, height, oldw, oldh); getLayout(width, height); createBitmapCells(); createBackgroundBitmap(width, height); createOverlays(); } MianGame游戏主要逻辑 package com.tpcstld.twozerogame; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class MainGame { public static final int SPAWN_ANIMATION = -1; public static final int MOVE_ANIMATION = 0; pub

文档评论(0)

1亿VIP精品文档

相关文档