Flash可以在Android游戏应用中用作动画吗?

时间:2011-07-17 19:55:11

标签: android flash animation

正如标题所说,可以在Android游戏中使用flash来显示动画吗?就像说当用户触摸触摸屏上的某个点时,屏幕上出现一个动画闪电箭头?

如果不可能,有什么替代方案?

感谢。

2 个答案:

答案 0 :(得分:1)

是的,它应该是可能的,最有可能通过WebView。但是,除非您的整个应用程序或至少需要显示闪电灯泡的部分是Web应用程序,否则无法在实际Android UI中使用onTouch中的动画闪电。

还有其他方法可以做到这一点,以及在Android中制作游戏的更好方法。我建议你看一下:http://developer.android.com/guide/topics/graphics/index.html

答案 1 :(得分: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

相关问题