2017-02-28 66 views
-2

我已经创建了一个应用程序,但我不能让“人”能够跑和跳(为寺庙运行) 我创建应用程序的第一部分,但我不知道如何添加此功能我想创建一个移动应用程序

package com.francesco.provadinuovo; 

import android.content.Intent; 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.view.View; 
import android.widget.Button; 

public class Main3Activity extends AppCompatActivity { 
    Intent MainActivity3; 
    Button button3; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main3); 

     button3= (Button) findViewById(R.id.button3); 
     button3.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 

      } 
     }); 
    } 
} 

我想写:此搜索可以移动或跳跃,如果触摸东西游戏结束

+1

image1的是什么?我想我们需要了解更多的代码来帮助你,看看[问]。 – Alex

+0

好吧,我会做到这一点,此搜索是一个“人”,但它是唯一的男人的形象......我怎么可能使它能跳?抱歉,但我在节目是新 – frlaka

回答

1

你显然需要的是一个动画,你应该看看这些链接 - >

一般动画https://developer.android.com/reference/android/view/animation/Animation.html

翻译动画https://developer.android.com/reference/android/view/animation/TranslateAnimation.html

下面是一些示例代码:

ImageView image = (ImageView) findViewById(R.id.image1); 
TranslateAnimation jumper = new TranslateAnimation(0f, 1f, 0f, 1f); 
jumper.setDuration(1000); // animation duration in milliseconds 
jumper.setFillAfter(true); // If fillAfter is true, the transformation that this animation performed will persist when it is finished. 
if (image != null) { 
    image.startAnimation(jumper); 
} 
+1

太感谢你了 – frlaka

+1

能否请你记住我的答案选择? – Alex

+1

我该怎么办? – frlaka

相关问题