0

我写了一个简单的游戏: https ://play.google.com/store/apps/details?id= com.ggimer.memorygradladzieci 请看滚轮图标 - 选项。// ibtn_menu_opcje 为什么我点击它时只有这个图标会消失?

活动:

private void Opcje() {
    if (!trwa_akcja) {
        if (!pierwsze_nacisniecie){
            pierwsze_nacisniecie = true;
            opcje_layout.setVisibility(View.VISIBLE);
            txt_dziura.startAnimation(rotate_animation);
            ibtn_menu_opcje.startAnimation(rotate_animation);//TODO
            opcje_layout.startAnimation(translate_animation);
        } else {
            txt_dziura.startAnimation(rotate_animation);
            ibtn_menu_opcje.startAnimation(rotate_animation_back);
            opcje_layout.startAnimation(translate_animation_back);
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    pierwsze_nacisniecie = false;
                    trwa_akcja = false;
                    opcje_layout.setVisibility(View.INVISIBLE);
                }
            }, 1000);
        } // if (!pierwsze_nacisniecie)
    } // if(!trwa_akcja) 
} // Opcje()

和动画:

private void WczytanieAnimacji() {
    translate_animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -2, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); 
    translate_animation.setDuration(1000);
    translate_animation_back = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -2, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); 
    translate_animation_back.setDuration(1000);
    rotate_animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    rotate_animation.setDuration(1000); 
    rotate_animation_back = new RotateAnimation(360, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    rotate_animation_back.setDuration(1000); 
    rotate_animation_back.setRepeatCount(0);

    // animacje pomocy
    pomoc_translate_w_lewo_1 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 3, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_lewo_1.setDuration(1000);
    pomoc_translate_w_lewo_2 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 3, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_lewo_2.setDuration(2000);
    pomoc_translate_w_prawo_1 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -3, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_prawo_1.setDuration(5000);
    pomoc_translate_w_prawo_2 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -4, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_prawo_2.setDuration(3000);
    pomoc_translate_w_prawo_30 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -4, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_prawo_30.setDuration(3000);
    pomoc_translate_w_lewo_45 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 3, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 3, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_lewo_45.setDuration(3000);
    pomoc_translate_w_dol_strzalka = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -3, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_dol_strzalka.setDuration(3000);
    pomoc_translate_w_dol_trudnosc = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 10); 
    pomoc_translate_w_dol_trudnosc.setDuration(12000);
    pomoc_translate_w_dol_menu= new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0); 
    pomoc_translate_w_dol_menu.setDuration(1000);

    napisy_translate = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1); 
    napisy_translate.setDuration(60000);
    napisy_alpha = new AlphaAnimation(0.1f, 1f); 
    napisy_alpha.setDuration(2000);

    pomoc_alpha_on = new AlphaAnimation(0.0f, 1f); 
    pomoc_alpha_on.setDuration(2000);
    pomoc_alpha_on2 = new AlphaAnimation(0.0f, 1f); 
    pomoc_alpha_on2.setDuration(3000);
    pomoc_alpha_off = new AlphaAnimation(1f, 0.0f); 
    pomoc_alpha_off.setDuration(2000);
    pomoc_alpha_off2 = new AlphaAnimation(1f, 0.0f); 
    pomoc_alpha_off2.setDuration(90000);
    pomoc_alpha_off3 = new AlphaAnimation(1f, 0.0f); 
    pomoc_alpha_off3.setDuration(3000);

    pomoc_scale_up = new ScaleAnimation(1f, 2f, 1f, 2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    pomoc_scale_up.setDuration(3000); 
    pomoc_scale_down = new ScaleAnimation(2f, 1f, 2f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    pomoc_scale_down.setDuration(3000);

    // kontenery animacji
    sets1 = new AnimationSet(false);
    sets1.addAnimation(pomoc_translate_w_dol_trudnosc); 
    sets1.addAnimation(pomoc_alpha_off2); 

    sets2 = new AnimationSet(false);
    sets2.addAnimation(pomoc_scale_up); 
    sets2.addAnimation(pomoc_alpha_off3); 
    sets2.setRepeatCount(0);

    sets3 = new AnimationSet(false);
    sets3.addAnimation(pomoc_scale_down); 
    sets3.addAnimation(pomoc_alpha_on2); 
    sets3.setRepeatCount(0);

    sets_napisy = new AnimationSet(false);
    sets_napisy.addAnimation(napisy_translate); 
    sets_napisy.addAnimation(napisy_alpha); 
    sets_napisy.setRepeatCount(0);

    sets_napisy_back = new AnimationSet(false);
    sets_napisy_back.addAnimation(pomoc_translate_w_dol_menu); 
    sets_napisy_back.addAnimation(napisy_alpha); 
    sets_napisy_back.setRepeatCount(0);

} // WczytanieAnimacji()

当我评论 ibtn_menu_opcje 行时,不同的视图消失了:/

如何解决?

4

0 回答 0