Android Open Source - FlappyCow Coin






From Project

Back to project page FlappyCow.

License

The source code is released under:

MIT License

If you think the Android project FlappyCow listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * A Coin/*  ww  w.j a  va 2  s .c o m*/
 * 
 * @author Lars Harmsen
 * Copyright (c) <2014> <Lars Harmsen - Quchen>
 */

package com.quchen.flappycow.sprites;

import com.quchen.flappycow.Game;
import com.quchen.flappycow.GameView;
import com.quchen.flappycow.MainActivity;
import com.quchen.flappycow.R;
import com.quchen.flappycow.Util;

import android.graphics.Bitmap;

public class Coin extends PowerUp {
  /**
   * Static bitmap to reduce memory usage.
   */
  public static Bitmap globalBitmap;
  private static int sound = -1;

  public Coin(GameView view, Game game) {
    super(view, game);
    if(globalBitmap == null){
      globalBitmap = Util.getScaledBitmapAlpha8(game, R.drawable.coin);
    }
    this.bitmap = globalBitmap;
    this.width = this.bitmap.getWidth()/(colNr = 12);
    this.height = this.bitmap.getHeight();
    this.frameTime = 1;
    if(sound == -1){
      sound = Game.soundPool.load(game, R.raw.coin, 1);
    }
  }

  /**
   * When eaten the player will turn into nyan cat.
   */
  @Override
  public void onCollision() {
    super.onCollision();
    playSound();
    game.increaseCoin();
  }
  
  private void playSound(){
    Game.soundPool.play(sound, MainActivity.volume, MainActivity.volume, 0, 0, 1);
  }
  
  @Override
  public void move() {
    changeToNextFrame();
    super.move();
  }
}




Java Source Code List

com.quchen.flappycow.About.java
com.quchen.flappycow.AccomplishmentBox.java
com.quchen.flappycow.GameOverDialog.java
com.quchen.flappycow.GameView.java
com.quchen.flappycow.Game.java
com.quchen.flappycow.MainActivity.java
com.quchen.flappycow.StartscreenView.java
com.quchen.flappycow.Util.java
com.quchen.flappycow.sprites.Background.java
com.quchen.flappycow.sprites.Coin.java
com.quchen.flappycow.sprites.Cow.java
com.quchen.flappycow.sprites.Frontground.java
com.quchen.flappycow.sprites.NyanCat.java
com.quchen.flappycow.sprites.Obstacle.java
com.quchen.flappycow.sprites.PauseButton.java
com.quchen.flappycow.sprites.PlayableCharacter.java
com.quchen.flappycow.sprites.PowerUp.java
com.quchen.flappycow.sprites.Rainbow.java
com.quchen.flappycow.sprites.Spider.java
com.quchen.flappycow.sprites.Sprite.java
com.quchen.flappycow.sprites.Toast.java
com.quchen.flappycow.sprites.Tutorial.java
com.quchen.flappycow.sprites.WoodLog.java