⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spritemanager.java

📁 一款新手改造的J2me手机游戏项目
💻 JAVA
字号:
package com.ejoy;

import java.io.IOException;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.Sprite;

//Download by http://www.codefans.net
public class SpriteManager 
{
	
	private GameMIDlet m_gm;
	private int m_spName;
	
	public final static int STAND=0;
	public final static int WALK=1;
	public final static int ATTACK=2;
	
	
	
	public final static int ROLE_DIAOCHAN=0;
	public final static int ROLE_ZHANGFEI=1;
	public final static int NPC_ZHANGLIAO=2;
	public final static int NPC_CHANGBIN=3;
	public final static int NPC_DUANBIN=4;
	public final static int NPC_TANMA=5;
	
	
	public Sprite standSprite=null;
	public Sprite walkSprite=null;
	public Sprite attackSprite=null;
	public Sprite orgsp=null;
	
	public int currentState=0;
	public int frame=0;
	
	
	
	public SpriteManager(GameMIDlet gm,int spName) throws IOException
	{
		m_gm=gm;
		m_spName=spName;
		switch(spName)
		{
			case ROLE_DIAOCHAN:
				/*standSprite=new MySprite(Image.createImage(GameMIDlet.PATH_DC_STAND),23,23,spName);
				walkSprite=new MySprite(Image.createImage(GameMIDlet.PATH_DC_WALK),23,23,spName);*/
				break;
			case ROLE_ZHANGFEI:
				break;
			case NPC_DUANBIN:
				/*standSprite=new MySprite(Image.createImage(GameMIDlet.PATH_DB_STAND),23,23,spName);
				walkSprite=new MySprite(Image.createImage(GameMIDlet.PATH_DB_WALK),23,23,spName);
				break;*/
				
		}
	}
	
	
	public int getSpriteName()
	{
		return m_spName;
	}
	
	public void setCurrentSprite(Sprite sp)
	{
		orgsp=sp;
	}
	
	public void setState(int states)
	{
		switch(states)
		{
			case STAND:
				//switch()
			
			
		}
	}
	
	
	public void setAction(int xPos,int yPos,int actionStyle)
	{
			switch(currentState)
			{
				
				case GameCanvas.UP:
					if(orgsp==walkSprite)
					{
						orgsp.setFrame((frame)%standSprite.getFrameSequenceLength());
						if(true)
						{
							orgsp.setRefPixelPosition(walkSprite.getRefPixelX()+xPos, walkSprite.getRefPixelY()+yPos);
						}
					}
					break;
					
				case GameCanvas.DOWN:
					if(orgsp==walkSprite)
					{
						orgsp.setFrame((frame)%standSprite.getFrameSequenceLength());
						if(true)
						{
							orgsp.setRefPixelPosition(walkSprite.getRefPixelX()+xPos, walkSprite.getRefPixelY()+yPos);
						}
					}
					break;
					
				case GameCanvas.RIGHT:
					if(orgsp==walkSprite)
					{
						orgsp.setFrame((frame)%standSprite.getFrameSequenceLength());
						if(true)
						{
							orgsp.setRefPixelPosition(walkSprite.getRefPixelX()+xPos, walkSprite.getRefPixelY()+yPos);
						}
					}
					break;
					
				case GameCanvas.LEFT:
					if(orgsp==walkSprite)
					{
						orgsp.setFrame((frame)%standSprite.getFrameSequenceLength());
						if(true)
						{
							orgsp.setRefPixelPosition(walkSprite.getRefPixelX()+xPos, walkSprite.getRefPixelY()+yPos);
						}
					}
					break;
					
				case GameCanvas.FIRE:
					if(orgsp==attackSprite)
					{
						orgsp.setFrame((frame)%standSprite.getFrameSequenceLength());
						if(true)
						{
							orgsp.setRefPixelPosition(walkSprite.getRefPixelX()+xPos, walkSprite.getRefPixelY()+yPos);
						}
					}
					break;
				/*case STAND:
				
					standSprite.setFrame((frame)%standSprite.getFrameSequenceLength());
					break;
				case WALK:
					walkSprite.setFrame((frame)%standSprite.getFrameSequenceLength());
					break;
				case ATTACK:
					//attackSprite.defineCollisionRectangle(arg0, arg1, arg2, arg3);
					attackSprite.setFrame((frame)%standSprite.getFrameSequenceLength());
					break;
				default:
					standSprite.setFrame((frame)%standSprite.getFrameSequenceLength());*/
			}
			
			
			
		
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -