文件名称:九宫格牌翻转游戏demo
文件大小:1.76MB
文件格式:ZIP
更新时间:2018-05-28 15:40:36
ImageVeiw 翻转游戏
java关键代码:
mText = (TextView) findViewById(R.id.textView1);
mImageView01 = (ImageView) findViewById(R.id.m1);
mButton = (Button) findViewById(R.id.button1);
randon();
mImageView01.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
if(check1 == true && num > 0 && num1 == false)
{
num--;
num1 = true;
choose1 = true;
if(turn1 == false)
{
turnAnim(mImageView01,s1[0]);
if(s1[0] == R.drawable.b)
{
num = 0 ;
friendState = true;
}
turn1 = true;
}
}
});
mButton.setOnClickListener(new Button.OnClickListener() {
@SuppressWarnings("deprecation")
public void onClick(View v) {
friendState = false;
xianshi = 3;
mText.setText("还剩"+xianshi+"次机会。");
num = 3;
});
}
/*往回洗牌的动画*/
public void backAnim(final ImageView a)
{
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.back_scale);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
a.setImageDrawable(getResources().getDrawable(
R.drawable.pbg));
// bool = true;
//通过AnimationUtils得到动画配置文件(/res/anim/front_scale.xml),然后在把动画交给ImageView
a.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.front));
}
});
a.startAnimation(animation);
}
/*翻牌的动画*/
public void turnAnim(final ImageView a,final int b)
{
Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.back_scale);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
a.setImageDrawable(getResources().getDrawable(b));
// bool = true;
//通过AnimationUtils得到动画配置文件(/res/anim/front_scale.xml),然后在把动画交给ImageView
a.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.front));
}
});
a.startAnimation(animation);
if (b == R.drawable.b) {
mText.setText("哇!你猜对了噢!!拍拍手!");
} else {
if(xianshi >= 1)
{
mText.setText("还剩"+xianshi+"次机会。");
}
else{
mText.setText("机会已用完!");
}
}
}
private void randon() {
// TODO Auto-generated method stub
for (int i = 0; i < 9; i++) {
int tmp = s1[i];
int s = (int) (Math.random() * 9);
s1[i] = s1[s];
s1[s] = tmp;
}
}
}
res/layout/activity_main.xml:
【文件预览】:
Game
----.project(840B)
----bin()
--------AndroidManifest.xml(874B)
--------jarlist.cache(120B)
--------dexedLibs()
--------Game.apk(356KB)
--------res()
--------resources.ap_(118KB)
--------classes()
--------classes.dex(696KB)
----ic_launcher-web.png(50KB)
----AndroidManifest.xml(874B)
----proguard-project.txt(781B)
----libs()
--------android-support-v4.jar(607KB)
----src()
--------com()
----project.properties(563B)
----res()
--------values()
--------values-sw720dp-land()
--------layout()
--------drawable-ldpi()
--------drawable-hdpi()
--------values-v11()
--------anim()
--------drawable-mdpi()
--------values-sw600dp()
--------drawable-xhdpi()
--------drawable-xxhdpi()
--------menu()
--------values-v14()
----.classpath(475B)
----gen()
--------com()
----assets()