当前位置: 首页>>代码示例>>Java>>正文


Java SpriteSheet.getSprite方法代码示例

本文整理汇总了Java中org.newdawn.slick.SpriteSheet.getSprite方法的典型用法代码示例。如果您正苦于以下问题:Java SpriteSheet.getSprite方法的具体用法?Java SpriteSheet.getSprite怎么用?Java SpriteSheet.getSprite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.newdawn.slick.SpriteSheet的用法示例。


在下文中一共展示了SpriteSheet.getSprite方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWallImage

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
private static Image getWallImage(GameMap map, int x, int y) {
	SpriteSheet sheet = ResourceManager.getSpriteSheet("walls");
	Image tile;

	boolean above = isWall(map, x, y - 1);
	boolean left = isWall(map, x - 1, y);
	boolean right = isWall(map, x + 1, y);
	boolean below = isWall(map, x, y + 1);

	int index = calculateTileIndex(above, below, left, right);
	if (index < 10) {
		tile = sheet.getSprite(index, 0);
	} else {
		tile = sheet.getSprite(index - 10, 1);
	}
	return tile;
}
 
开发者ID:Gornova,项目名称:CryptoRl2,代码行数:18,代码来源:TileFactory.java

示例2: loadPlayerFeet

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public static Animation[] loadPlayerFeet() {
	SpriteSheet sprites = new SpriteSheet(loadImage("feet.png"), 64, 64);

	Animation[] model = new Animation[8];

	Image[] frames = new Image[8];
	for (int angle = 0, j = 0; angle < 360; angle += 45, j++) {
		for (int i = 0; i < 8; i++) {
			Image temp = sprites.getSprite(0, i);
			temp.rotate(angle);
			frames[i] = temp;
		}
		model[j] = new Animation(frames, 100);
	}

	return model;
}
 
开发者ID:JavaJumperStudios,项目名称:Saboteur,代码行数:18,代码来源:RessourceManager.java

示例3: init

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
	fontImage = new Image("res/font/lcd_solid_9_00.png");
	fontImage.setFilter(Image.FILTER_NEAREST);
	font = new AngelCodeFont("res/font/lcd_solid_9.fnt", fontImage);
	
	backButtonImage = new Image("res/img/ui/backButton.png");
	backButtonImage.setFilter(Image.FILTER_NEAREST);
	backButton = new Button(80f, 160f, backButtonImage.getWidth(), backButtonImage.getHeight(), backButtonImage);	
	
	dealWithIt = new Image("res/img/ui/dealwithit.png");
	dealWithIt.setFilter(Image.FILTER_NEAREST);
	dealWithItXPos = 36f;
	dealWithItYPos = -20f;
	dealWithItYTarget = 72f;
	printTheEnd = 0;
	printTheEndTarget = 1000;
	
	// Sprite sheep strikes back
	SpriteSheet spriteSheep = new SpriteSheet("res/img/character/bartender alpha.png", 16, 16);
	characterImage =  spriteSheep.getSprite(3, 0);
	characterImage.setFilter(Image.FILTER_NEAREST);
	
	bookImage = new Image("res/img/items/book.png");
	bookImage.setFilter(Image.FILTER_NEAREST);
}
 
开发者ID:lucas-tulio,项目名称:reddit-game-jam-5,代码行数:27,代码来源:FinishedState.java

示例4: Energy

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Energy(float x, float y, int charge){
	super(x,y,ItemListEnum.ENERGY);
	weight = 100;
	
	gbtype = GameBodyType.ENERGY;
	
	this.charge = charge;	
	this.halfSize.set(0.3f,0.3f);
	
	try {
		sprites = new SpriteSheet("assets/textures/energy.png",64,64);
		image = sprites.getSprite(0, 0);
	} catch (SlickException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:17,代码来源:Energy.java

示例5: init

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
@Override
public void init(GameContainer gc, StateBasedGame sbg)
		throws SlickException {
	
	background = new Image("res/background.png");
	
	back = Main.loadImage("res/login.png");
	
	sheet = new SpriteSheet(Main.loadImage("res/textbox.png"), 256, 32);
	
	user = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 128, gc.getHeight() / 2 - back.getHeight() / 2 + 65);
		user.setMouseOverImage(sheet.getSprite(0, 1));
		user.setMouseDownImage(sheet.getSprite(0, 1));
	password = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 128, gc.getHeight() / 2 - back.getHeight() / 2 + 115);
		password.setMouseOverImage(sheet.getSprite(0, 1));
		password.setMouseDownImage(sheet.getSprite(0, 1));
	go = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1), gc.getWidth() / 2 + back.getWidth() / 2 - 40, gc.getHeight() / 2 + back.getHeight() / 2 - 40);
		go.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1));
	register = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), 4, gc.getHeight() - 40);
		register.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
	
	errorImage = Main.loadImage("res/error.png");
	
	this.connect = new LoginScreenConnectThread();
		
	gc.getInput().addKeyListener(new LoginScreenKeyListener());
		
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:29,代码来源:LoginScreen.java

示例6: Entity

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
protected Entity(int id, SpriteSheet spriteSheet) throws SlickException {
	
	this(id);
	
	// Create the SpriteSheet
	this.spriteSheet = spriteSheet;
	
	// Create and load the Standing Still Images
	image = new Image[4];
	for(int i = 0; i < image.length; i++) {
		image[i] = spriteSheet.getSprite(0, i);
		image[i].setFilter(Image.FILTER_NEAREST);
	}
	
	// Create the Animations
	frameDuration = 150;
	animation = new Animation[4];
	animation[DOWN_RIGHT] = new Animation(new Image[] {image[DOWN_RIGHT], spriteSheet.getSprite(1, 0),  spriteSheet.getSprite(2, 0), spriteSheet.getSprite(1, 0)},  frameDuration);
	animation[DOWN_LEFT] = new Animation(new Image[] {image[DOWN_LEFT], spriteSheet.getSprite(1, 1),  spriteSheet.getSprite(2, 1), spriteSheet.getSprite(1, 1)},  frameDuration);
	animation[UP_LEFT] = new Animation(new Image[] {image[UP_LEFT], spriteSheet.getSprite(1, 2),  spriteSheet.getSprite(2, 2), spriteSheet.getSprite(1, 2)},  frameDuration);
	animation[UP_RIGHT] = new Animation(new Image[] {image[UP_RIGHT], spriteSheet.getSprite(1, 3),  spriteSheet.getSprite(2, 3), spriteSheet.getSprite(1, 3)}, frameDuration);
	
	for(int i = 0; i < animation.length; i++) {	
		animation[i].setAutoUpdate(true);
		animation[i].setPingPong(false);
	}
	
	// Some basic Sprite parameters
	spriteWidth = image[0].getWidth();
	spriteHeight = image[0].getHeight();
	facingDirection = DOWN_RIGHT;
	scale = 1f;
}
 
开发者ID:lucas-tulio,项目名称:awesome-game-store,代码行数:34,代码来源:Entity.java

示例7: Dos

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Dos(float x, float y) throws SlickException {
	super(x, y);
	SpriteSheet dosSheet = new SpriteSheet(
			"org/dosimonline/res/sprites/dos.png", 20, 36);
	dosWalkLeft = new Animation();
	dosWalkLeft.setAutoUpdate(true);
	dosWalkLeft.addFrame(
			dosSheet.getSprite(0, 0).getFlippedCopy(true, false), 150);
	dosWalkLeft.addFrame(
			dosSheet.getSprite(1, 0).getFlippedCopy(true, false), 150);

	dosWalkRight = new Animation();
	dosWalkRight.setAutoUpdate(true);
	dosWalkRight.addFrame(dosSheet.getSprite(0, 0), 150);
	dosWalkRight.addFrame(dosSheet.getSprite(1, 0), 150);
	dosStanding = dosSheet.getSprite(0, 0);
	dosJumping = dosSheet.getSprite(2, 0);
	define("right", Input.KEY_D);
	define("left", Input.KEY_A);
	define("up", Input.KEY_W);
	define("q", Input.KEY_Q);
	setHitBox(0, 0, dosStanding.getWidth(), dosStanding.getHeight());
	addType("Dos");

	score = 0;
	life = 5;
	velocityY = 0;
	jumpAllowed = false;
}
 
开发者ID:Dosim-Online,项目名称:DosimOnline.Models,代码行数:30,代码来源:Dos.java

示例8: Battery

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Battery(float x, float y){
	super(x,y,ItemListEnum.BATTERY);
	weight = 0;
	halfSize.set(0.3f,0.3f);
	gbtype = GameBodyType.BATTERY;
	try {
		sprites = new SpriteSheet("assets/textures/battery.png",64,64);
		image = sprites.getSprite(0, 0);
	} catch (SlickException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:13,代码来源:Battery.java

示例9: init

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void init(GameContainer gc, StateBasedGame sbg)
		throws SlickException {
	
	errorImage = Main.loadImage("res/error2.png");
	
	lastMouseX = gc.getInput().getAbsoluteMouseX();
	lastMouseY = gc.getInput().getAbsoluteMouseY();
	
	gc.setMouseCursor(Main.CURSOR_IMAGES.getSprite(1, 0), 16, 16);
	
	FONT = new UnicodeFont("res/Anonymous_Pro.ttf", 12, false, false);

	FONT.addAsciiGlyphs();
	FONT.getEffects().add(new ColorEffect());
	FONT.loadGlyphs();
	
	coin = Main.loadImage("res/coin.png");

	EditorKeyListener listener = new EditorKeyListener(this);
	gc.getInput().addKeyListener(listener);
	
	tiles = new SpriteSheet(Main.loadImage("res/tiles.png"), 32, 32);
	
	play = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1), 4, gc.getHeight() - 40);
		play.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1));
	stop = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 2), 44, gc.getHeight() - 40);
		stop.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 2));
	help = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), 84, gc.getHeight() - 40);
		help.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
	failed = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 3), gc.getWidth() / 2 - 16, gc.getHeight() / 2 + 40);
		failed.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 3));
	pause = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 0), 8, 8);
		pause.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 0));
		
	menu = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 16);
		menu.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
		
	SpriteSheet sheet = new SpriteSheet(Main.loadImage("res/tweet.png"), 128, 32);
	
	tweet = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 56);
		tweet.setMouseDownImage(sheet.getSprite(0, 1));
	scores = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 96);
		scores.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));

	coins = 0;
	
	arrow = Main.loadImage("res/arrow.png");
	
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:52,代码来源:Game.java

示例10: Door

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Door(int x, int y, int dir, Game game, int listenerLevel) throws SlickException {
	
	super(x, y, 5, dir, "", false, game, "door", true, listenerLevel);
	
	SpriteSheet sheet = new SpriteSheet(Main.loadImage("res/door.png"), 32, 40);
	
	if (dir == 0 | dir == 2) {
		
		open = sheet.getSprite(1, 1);
		closed = sheet.getSprite(1, 0);
		
	} else {
		
		open = sheet.getSprite(2, 1);
		closed = sheet.getSprite(2, 0);
		
	}
	
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:20,代码来源:Door.java

示例11: Customer

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Customer(int id, Font font, Font shadowFont, SpriteSheet spriteSheet, SpriteSheet playingSpriteSheet,
		ArrayList<Action> actions, int simulationSpeed, Store store) throws SlickException {

	// Character Constructor
	super(id, spriteSheet, font, shadowFont);
	
	// There are 3 possible Character speeds: slow (4/12), normal (7/12) and fast (1/12).
	int randomSpeedType = new Random().nextInt(12);
	if(randomSpeedType < 1) {
		
		// Fast
		maxIdleTime = (int)((new Random().nextInt(10000) + 5000) / simulationSpeed);
		movementInterval = (int)((new Random().nextInt(300) + 500) / simulationSpeed);
		maxWaitingTime = 5000;
		speed = 0.07f;
		
	} else if(randomSpeedType > 0 && randomSpeedType < 5) {
		
		// Slow
		maxIdleTime = (int)((new Random().nextInt(30000) + 5000) / simulationSpeed);
		movementInterval = (int)((new Random().nextInt(2000) + 500) / simulationSpeed);
		maxWaitingTime = 15000;
		speed = 0.03f;
		
	} else {
		
		// Normal
		maxIdleTime = (int)((new Random().nextInt(20000) + 5000) / simulationSpeed);
		movementInterval = (int)((new Random().nextInt(1000) + 500) / simulationSpeed);
		maxWaitingTime = 10000;
		speed = 0.05f;
	}
	
	// Fair Price Types
	int fpType = getCustomerFairPriceType();
	sellFairPriceModifier = getSellFairPrice(fpType);
	rentFairPriceModifier = getRentFairPrice(fpType);
	playFairPriceModifier = getPlayFairPrice(fpType);
	
	// Actions received from Game and Console
	this.actions = actions;
	currentAction = null;
	currentIdleTime = maxIdleTime;	// There's no delay on the first Action
	currentWaitingTime = 0;
	chanceToSpeak = 10;
	// Actions that belong to the Customer itself, depending on the Fair Price Type
	this.generateOwnActions(fpType, store);
	
	// Create and load the Playing
	playingSprites = new Image[4];
	for(int i = 0; i < playingSprites.length; i++) {
		playingSprites[i] = playingSpriteSheet.getSprite(i, 0);
		playingSprites[i].setFilter(Image.FILTER_NEAREST);
	}
}
 
开发者ID:lucas-tulio,项目名称:awesome-game-store,代码行数:56,代码来源:Customer.java

示例12: Enemy

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Enemy(int xTile, int yTile) throws SlickException {
	
	this.xTile = xTile;
	this.yTile = yTile;
	this.xPos = xTile * 16;
	this.yPos = yTile * 16;
	
	// Basic properties
	speed = 0.02f;
	isMoving = false;
	isAlive = true;
	maxDetectionRange = 64;
	maxDetectionTime = 1000;
	maxIdleTime = 2000;
	detectionTime = 0;
	readNextStep = false;
	isChasing = false;
	
	// Sound
	deathSound = new Sound("res/sfx/death.wav");
	detectionSound = new Sound("res/sfx/monster.wav");
	alreadyPlayedDeathSound = false;
	alreadyPlayedDetectionSound = false;
	
	// Open the Sprite Sheep
	spriteSheep = new SpriteSheet("res/img/enemy/zombie alpha.png", 16, 20);
	
	// Create the Images and the Animations
	image = new Image[4];
	animation = new Animation[4];
	animationDuration = 300;
	rectangle = new Rectangle(xPos, yPos, 16, 16);
	
	// The Standing Still images are on the middle column
	image[Entity.UP] = spriteSheep.getSprite(1, 0);
	image[Entity.RIGHT] = spriteSheep.getSprite(1, 1);
	image[Entity.DOWN] = spriteSheep.getSprite(1, 2);
	image[Entity.LEFT] = spriteSheep.getSprite(1, 3);
	
	// The Animated images are on the rows below
	animation[Entity.UP] = new Animation(new Image[]{image[Entity.UP], spriteSheep.getSprite(0, 0), spriteSheep.getSprite(2, 0)}, animationDuration, false);
	animation[Entity.RIGHT] = new Animation(new Image[]{image[Entity.RIGHT], spriteSheep.getSprite(0, 1), spriteSheep.getSprite(2, 1)}, animationDuration, false);
	animation[Entity.DOWN] = new Animation(new Image[]{image[Entity.DOWN], spriteSheep.getSprite(0, 2), spriteSheep.getSprite(2, 2)}, animationDuration, false);
	animation[Entity.LEFT] = new Animation(new Image[]{image[Entity.LEFT], spriteSheep.getSprite(0, 3), spriteSheep.getSprite(2, 3)}, animationDuration, false);

	// Apply animation settings
	for(int i = 0; i < 4; i++) {
		animation[i].setPingPong(true);
		for(int j = 0; j < 3; j++) {
			animation[i].setDuration(j, animationDuration);
		}
	}
	
	// Adjusts positions
	updateTiles();
	snapToGrid();
}
 
开发者ID:lucas-tulio,项目名称:reddit-game-jam-5,代码行数:58,代码来源:Enemy.java

示例13: Character

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public Character(int xTile, int yTile) throws SlickException {
	
	this.xTile = xTile;
	this.yTile = yTile;
	this.xPos = xTile * 16;
	this.yPos = yTile * 16;
	
	// Basic properties
	speed = 0.03f;
	isMoving = false;
	isAlive = true;
	isRunning = false;
	
	// Open the Sprite Sheep
	spriteSheep = new SpriteSheet("res/img/character/bartender alpha.png", 16, 16);
	
	// Create the Images and the Animations
	image = new Image[4];
	animation = new Animation[4];
	animationDuration = 200;
	rectangle = new Rectangle(xPos, yPos, 16, 16);
	light = new Light(0f, 0f);
	
	// The Standing Still images are on the first row
	image[Entity.UP] = spriteSheep.getSprite(0, 0);
	image[Entity.RIGHT] = spriteSheep.getSprite(1, 0);
	image[Entity.DOWN] = spriteSheep.getSprite(2, 0);
	image[Entity.LEFT] = spriteSheep.getSprite(3, 0);
	imageDead = new Image("res/img/character/bartender dead.png");
	imageDead.setFilter(Image.FILTER_NEAREST);
	
	// The Animated images are on the rows below
	animation[Entity.UP] = new Animation(new Image[]{image[Entity.UP], spriteSheep.getSprite(0, 1), spriteSheep.getSprite(1, 1)}, animationDuration, false);
	animation[Entity.RIGHT] = new Animation(new Image[]{image[Entity.RIGHT], spriteSheep.getSprite(0, 2), spriteSheep.getSprite(1, 2)}, animationDuration, false);
	animation[Entity.DOWN] = new Animation(new Image[]{image[Entity.DOWN], spriteSheep.getSprite(0, 3), spriteSheep.getSprite(1, 3)}, animationDuration, false);
	animation[Entity.LEFT] = new Animation(new Image[]{image[Entity.LEFT], spriteSheep.getSprite(0, 4), spriteSheep.getSprite(1, 4)}, animationDuration, false);

	// Apply animation settings
	for(int i = 0; i < 4; i++) {
		animation[i].setPingPong(true);
		for(int j = 0; j < 3; j++) {
			animation[i].setDuration(j, animationDuration);
		}
	}
}
 
开发者ID:lucas-tulio,项目名称:reddit-game-jam-5,代码行数:46,代码来源:Character.java

示例14: PressurePlate

import org.newdawn.slick.SpriteSheet; //导入方法依赖的package包/类
public PressurePlate(int x, int y, Game game, int listenerLevel) throws SlickException {
	
	super(x, y, 0, 0, "", false, game, "pressureplate", false, listenerLevel);
	
	SpriteSheet image = new SpriteSheet(Main.loadImage("res/pressureplate.png"), 32, 34);
	
	normal = image.getSprite(0, 0);
	pressed = image.getSprite(1, 0);
	
	active = false;
	
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:13,代码来源:PressurePlate.java


注:本文中的org.newdawn.slick.SpriteSheet.getSprite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。