package sample.game.model; import library.core.listener.OnCoreTouchUpListener; import library.core.model.CoreModel; import library.core.system.CoreImageData; import sample.game.controller.GameController; /** * 渡るボタン * @author 貴裕 * */ public class CrossButton extends CoreModel implements OnCoreTouchUpListener{ private GameController controller; private CoreImageData onImage; private CoreImageData offImage; private boolean canMove; //渡るボタンを押せるかどうか public CrossButton(CoreImageData offImage,CoreImageData onImage,GameController controller, float centerX, float centerY, float width, float height) { super(offImage, centerX, centerY, width, height); this.offImage=offImage; this.onImage=onImage; this.controller=controller; this.canMove=false; } public boolean isCanMove() { return canMove; } public void setCanMove(boolean canMove) { this.canMove = canMove; this.setShowView(true); //表示を消している可能性があるので、一応処理を入れる if(canMove){ this.setImageData(onImage); }else{ this.setImageData(offImage); } } @Override public void onTouchUp() { if(canMove){ //ボタンが押せる場合 canMove=false; controller.changeTurn(false); this.setShowView(false); } } }