📄 player.java
字号:
/*
*M3DEA - MOBILE 3D ENGINE API
*Copyright (C) 2006 Alexandre Watanabe alexandre_sw@yahoo.com.br
* Diego de Freitas zenon_cc@yahoo.com.br
* Paulo Rodrigo Priszculnik paulorp@paulorp.trix.net
* Rodrigo Arthur Lopes raspl@terra.com.br
*
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite
* 330, Boston, MA 02111-1307 USA
*
*/
package m3dea.entities;
import javax.microedition.m3g.*;
import m3dea.io.KeyEvent;
import m3dea.io.KeyListener;
/**
* Classe abstrata que representa um jogador. I
* Implementa a interface KeyListener para receber as telas pressionadas pelo usu醨io.
*/
public abstract class Player extends Sprite implements KeyListener
{
private Camera camera = null;
/** Creates a new instance of Player */
public Player()
{
}
/**
* Recupera Camera do Jogador
* @return Camera
*/
public Camera getCamera(){ return camera; }
/**
* Seta Camera que persegue o jogador
* @param cam Camera do jogador
*/
public void setCamera(Camera cam)
{
camera = cam;
camera.setAlignment(this.getMesh(), Node.ORIGIN, EntityManager.getInstance().getWorld(), Node.Y_AXIS);
camera.setScale(-1,1,-1);
}
/**
* Realiza uma transla玢o do Jogador na cena
* @param tx Transla玢o no eixo x
* @param ty Transla玢o no eixo y
* @param tz Transla玢o no eixo z
*/
public void translate(float tx, float ty, float tz)
{
super.translate(tx, ty, tz);
if( camera != null ) camera.translate(tx, ty, tz);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -