/*
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 */
package pacman;


import javafx.animation.Interpolator;
import javafx.animation.RotateTransition;
import javafx.animation.Timeline;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.transform.Rotate;
import javafx.util.Duration;
import static pacman.Pacman.*;


/**
 *
 * @author akouznet
 */
public class Coin extends ImageView {
    
    private static Image image = new Image(Coin.class.getResource("images/coin_sm.png").toExternalForm());

    public Coin() {
        super(image);
        setFitWidth(COIN_WIDTH);
        setFitHeight(COIN_WIDTH);
        setPreserveRatio(true);
        setX((CELL_WIDTH - COIN_WIDTH) / 2);
        setY((CELL_WIDTH - COIN_WIDTH) / 2);
        setTranslateZ(COIN_WIDTH);
        
        RotateTransition rotateTransition = new RotateTransition(Duration.millis(1500), this);
        rotateTransition.setByAngle(360);
        rotateTransition.setCycleCount(Timeline.INDEFINITE);
        rotateTransition.setInterpolator(Interpolator.LINEAR);
        rotateTransition.setAxis(Rotate.Y_AXIS);
        rotateTransition.playFrom(Duration.millis(1500 * Math.random()));
        
//        getGame().addAnimation(rotateTransition);
    }
}
