Mobile Terminal webpage game porting R & D framework [genie system-paper doll]

Source: Internet
Author: User

Now it's time to talk about the genie system paper dolls. In each RPG Game, there are similar real character styles displayed in the game. Of course, the presentation methods are different, and there are movable and fixed. There are generally two models: NPC characters, leading characters, and so on, which are derived from the genie system, where the leading character is movable, and the first person is mobile. In our game, I will not discuss the "4-direction, 8-direction" Genie System of character movement. We are working on the manifestation of the NPC character genie system. Its function is "Flip left and right, dynamic, speaking and fighting: in canvas Android, we use bitmap to draw images and control the reverse effects of materials.

The following describes how to create a layout in 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>

After the definition, you can create an NPC as an genie control!

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 stubthis.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();}@Overrideprotected 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>() {@Overridepublic void execute(CacheResult cacheResult) {if(cacheResult.isCached()) {String path = cacheResult.getCachedPath();final Bitmap bm = BitmapCache.Instance.getFileImageOrCache(path);TApp.getActivity().runOnUiThread(new Runnable() {@Overridepublic void run() {BitmapDrawable drwawable = new BitmapDrawable(bm);npcimg.setBackgroundDrawable(drwawable);}});}}});}

 

Then, the frame is displayed using the animation playback mechanism, so that the paper doll system is basically formed and can be moved. It can also be expanded.

Next I will paste the effect of the created genie System in the map system.

This is the city pool scenario of our game, where the NPC is very exquisite.

This is our leveling map. This map system is configured by the server. The coordinates, orientations, movements, and conversations of monsters can all be configured on the server.

Game group: [45578308] Welcome to group discussion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.