2011-07-17 29 views
3

正如標題所說,可以在Android遊戲中使用Flash來顯示動畫?就像用戶在觸摸屏上觸摸一個點時屏幕上出現的動畫閃電一樣?Flash可以在Android遊戲應用中用作動畫嗎?

如果這是不可能的,有什麼替代方法呢?

謝謝。

+0

Android的圖形和動畫院系大量用於顯示一個閃電。 對此使用Flash會浪費資源。 這聽起來像你正在開始使用Android的用戶界面。你能給我們多一點你想要完成的信息嗎?也許我們中的一個可以讓你走。 – mbarnes

回答

1

是的,它應該是可能的,很可能通過WebView。然而,除非您的整個應用程序或至少需要顯示閃電燈的部分是Web應用程序,否則實際Android UI中的onTouch中的動畫閃電是不可能的。

還有其他方法可以做到這一點,以及在Android中製作遊戲的更好方法。我建議你看看:http://developer.android.com/guide/topics/graphics/index.html

1

Android的圖形和動畫學院是足夠的顯示閃電。

對此使用Flash會浪費資源。

聽起來你正在開始使用Android的UI。你能給我們多一點你想要完成的信息嗎?也許我們中的一個可以讓你走吧。

在平均時間,也許這將有助於:

package com.arrdude.forumanswer; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.MotionEvent; 
import android.view.View; 
import android.view.View.OnTouchListener; 
import android.widget.FrameLayout; 
import android.widget.ImageView; 

public class TouchLightningActivity extends Activity implements OnTouchListener { 
    FrameLayout mainframe; 
    ImageView lightning; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     mainframe = (FrameLayout) findViewById(R.id.mainframe); 
     lightning = (ImageView) findViewById(R.id.imageView1); 
     mainframe.setOnTouchListener(this); 
    } 

    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     System.out.println(event); 
     //lots of interesting things going on here to look at if you are not yet familiar with touch listeners 
     if(event.getAction()==MotionEvent.ACTION_DOWN){ 
      lightning.setVisibility(View.VISIBLE); 
     }else if(event.getAction()==MotionEvent.ACTION_UP 
       || event.getAction()==MotionEvent.ACTION_OUTSIDE){ 
      lightning.setVisibility(View.INVISIBLE); 
     } 
     return false; 
    } 
} 

的main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainframe" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    android:layout_gravity="center" 
    android:background="@drawable/background" 
    > 

    <ImageView android:src="@drawable/lightning" 
     android:id="@+id/imageView1" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:visibility="invisible"></ImageView> 
</FrameLayout> 

的AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="com.arrdude.forumanswer" 
     android:versionCode="1" 
     android:versionName="1.0"> 
    <uses-sdk android:minSdkVersion="4" /> 

    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:name=".TouchLightningActivity" 
        android:label="@string/app_name" android:screenOrientation="landscape"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
</manifest> 

繪項目:

background.png

Before The Storm by Larisa Larisa: public domain image from here

lightning.png

相關問題