移动终端网页游戏移植研发框架【精灵系统-纸娃娃】
2012-03-02 22:22
411 查看
这下到了说精灵系统纸娃娃的时候了,在每款RPG游戏中都有类似的实体人物造型在游戏中呈现,当然呈现的方式不同,有可移动的,固定的。一般有两种模式,NPC人物,主角人物等类型,就是精灵系统的衍生,人物主角可移动的情况,和第一人称移动的,在我们这个游戏中,我不探讨人物移动【4方向,8方向】的精灵系统,我们做的是表现形式的NPC人物精灵系统,它拥有的功能就是【左右翻转,动态,说话,战斗】,在canvas android中我们利用到 Bitmap 绘制图像,控制素材的反转效果。
下面先在xml制作布局:
定义好之后就开始将NPC制作成精灵控件!
然后利用动画播放的机制,将帧显示出来,这样纸娃娃系统就基本成型了,而且能够动起来了。而且还可以拓展,这个就靠大家发挥了。
下面我贴一下制作成功的精灵系统在地图系统中的显示效果。
这就是我们游戏的城池场景,里面的NPC都是非常精美的。
这个就是我们的练级地图了,这套地图系统是由服务器配置的,怪物的坐标,朝向,动作,对话,都可以在服务器端配置。
游戏群:【45578308】欢迎进群讨论
下面先在xml制作布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_height="180dip" android:layout_width="150dip" android:gravity="center"> <TextView android:layout_height="wrap_content" android:text="npcname" android:id="@+id/npcname" style="@style/GameText" android:gravity="center" android:textColor="#FFCC00" android:textSize="11dip" android:background="@drawable/js_npc_textbd" android:layout_width="wrap_content" /> <ImageView android:layout_width="150dip" android:id="@+id/npcimg" android:layout_height="150dip" /> </LinearLayout> </LinearLayout>
定义好之后就开始将NPC制作成精灵控件!
Timer timer = new Timer(); private int i = 0; private int cutnum; private String npcname; private String npcurl; private String npcimgrul; private Context context; private Bitmap npcbitmap; private Boolean npcflag=false; private String monsetid; public String getMonsetid() { return monsetid; } public void setMonsetid(String monsetid) { this.monsetid = monsetid; } public TextView npcnametext; private ArrayList<Bitmap> NpcImgResList; public ImageView npcimg; NpcBody npcbody = new NpcBody(); public NpcView(Context context) { super(context); this.context=context; } public NpcView(Context context, AttributeSet attrs) { super(context, attrs); this.context=context; } public NpcView(Context context, AttributeSet attrs,String npcname,String npcimgrul,int cutnum,Boolean npcflag,String monsetid) { super(context, attrs); this.context=context; initMonster(npcname, npcimgrul, cutnum,npcflag,monsetid); } private void initMonster(String npcname2, String npcimgrul, int cutnum2,Boolean npcflag,String monsetid) { // TODO Auto-generated method stub this.npcname=npcname2; this.npcimgrul=npcimgrul; this.cutnum=cutnum2; this.npcflag= npcflag; setMonsetid(monsetid); forceInflate(); } public void initNpc(String npcname,String npcurl,int cutnum) { this.npcname=npcname; this.npcurl=npcurl; this.cutnum=cutnum; /*npcbitmap = BitmapFactory.decodeResource(this.getResources(), npcimgid);*/ NpcImgResList =npcbody.getNpcBody(cutnum, npcurl); forceInflate(); } public void forceInflate() { onFinishInflate(); } @Override protected void onFinishInflate() { super.onFinishInflate(); LayoutInflater li = LayoutInflater.from(getContext()); li.inflate(R.layout.view_npc, this); if(npcflag!=true) { internalOnFienishinflated(); } else { internalOnFienishinflated2(); } } public LayoutParams lp ; private void internalOnFienishinflated() { npcnametext = (TextView)findViewById(R.id.npcname); npcimg =(ImageView)findViewById(R.id.npcimg); npcnametext.setText(npcname); onplay(); } private void internalOnFienishinflated2() { npcnametext = (TextView)findViewById(R.id.npcname); npcimg =(ImageView)findViewById(R.id.npcimg); npcnametext.setText(npcname); if(npcimgrul.length()>0) { setMonsterImage(npcimgrul); } } private void setMonsterImage(String faceUrl) { LocalCache.getInstance(CacheValue.GameDataPack).useDownloadResource(faceUrl, new Action<CacheResult>() { @Override public void execute(CacheResult cacheResult) { if(cacheResult.isCached()) { String path = cacheResult.getCachedPath(); final Bitmap bm = BitmapCache.Instance.getFileImageOrCache(path); TApp.getActivity().runOnUiThread(new Runnable() { @Override public void run() { BitmapDrawable drwawable = new BitmapDrawable(bm); npcimg.setBackgroundDrawable(drwawable); } }); } } }); }
然后利用动画播放的机制,将帧显示出来,这样纸娃娃系统就基本成型了,而且能够动起来了。而且还可以拓展,这个就靠大家发挥了。
下面我贴一下制作成功的精灵系统在地图系统中的显示效果。
这就是我们游戏的城池场景,里面的NPC都是非常精美的。
这个就是我们的练级地图了,这套地图系统是由服务器配置的,怪物的坐标,朝向,动作,对话,都可以在服务器端配置。
游戏群:【45578308】欢迎进群讨论
相关文章推荐
- 移动终端网页游戏移植研发框架【道具系统】
- 移动终端网页游戏移植研发框架【服务器及客户端交互处理】
- 移动终端网页游戏移植研发框架【人物角色模型介绍】
- 移动终端网页游戏移植研发框架【客户端战斗系统】
- 移动终端网页游戏移植研发框架【带动画效果控件隐藏的方法】
- 移动终端网页游戏移植研发框架【android&IOS总汇】
- 王家林的81门一站式云计算分布式大数据&移动互联网解决方案课程第九门课程:Android系统移植及框架整合与维护
- 移动开发:S5PV210学习笔记——内核移植与文件系统构建
- 开源物联网通讯框架ServerSuperIO,成功移植到Windows10 IOT,在物联网和集成系统建设中降低成本。附:“物联网”交流大纲
- 移动终端管理系统的关键技术研究 - 转贴
- 制作jffs2文件系统 分类: 终端移植_文件系统 2013-07-10 14:36 261人阅读 评论(0) 收藏
- 百度移动终端研发工程师笔试题
- 移植Linux系统到iMX6开发板之LVDS显示屏驱动程序的框架分析与移植
- 基于移动平台的多媒体框架——移植SDL到Android
- 深入浅出 - Android系统移植与平台开发(十一) - Sensor HAL框架分析之一
- phonegap 3.40 for android移动开发框架window系统下安装过程
- 深入浅出 - Android系统移植与平台开发(十三) - Sensor HAL框架分析之三
- 【视频课程】Android底层开发关键技术—Android系统移植与HAL框架开发
- 移动终端系统的专利战争-Android的“专利门”
- 技术交底书(二)-----一种基于移动终端的安全防护系统