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


Java ResourceLoader.getResourceAsStream方法代码示例

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


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

示例1: loadDefinition

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Load the definition file and parse each of the sections
 * 
 * @param def The location of the definitions file
 * @param trans The color to be treated as transparent
 * @throws SlickException Indicates a failure to read or parse the definitions file
 * or referenced image.
 */
private void loadDefinition(String def, Color trans) throws SlickException {
	BufferedReader reader = new BufferedReader(new InputStreamReader(ResourceLoader.getResourceAsStream(def)));

	try {
		image = new Image(basePath+reader.readLine(), false, filter, trans);
		while (reader.ready()) {
			if (reader.readLine() == null) {
				break;
			}
			
			Section sect = new Section(reader);
			sections.put(sect.name, sect);
			
			if (reader.readLine() == null) {
				break;
			}
		}
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to process definitions file - invalid format?", e);
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:31,代码来源:PackedSpriteSheet.java

示例2: loadMap

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public void loadMap(String name) {
	try {
		ObjectInputStream oos = new ObjectInputStream(ResourceLoader
				.getResourceAsStream(GamePanel.resfolder + "stages" + File.separator + name + ".map"));
		TileMapData data = (TileMapData) oos.readObject();
		this.tiles = data.tiles;
		width = data.width;
		height = data.height;
		oos.close();

		return;
	} catch (Exception e) {
		System.err.println("Map: '" + name + "' is corrupt");
		e.printStackTrace();
	}
}
 
开发者ID:Timbals,项目名称:YellowSquare,代码行数:17,代码来源:TileMap.java

示例3: Score

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Initialise resources
 */
public Score() {
	readHighScore();
	//load a default java font
    Font awtFont = new Font("Times New Roman", Font.BOLD, 24);
    font = new TrueTypeFont(awtFont, antiAlias);
     
    // load font from file
    try {
        InputStream inputStream = ResourceLoader.getResourceAsStream("res/fonts/brick.ttf");
         
        Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
        awtFont2 = awtFont2.deriveFont(50f); // set font size
        font2 = new TrueTypeFont(awtFont2, antiAlias);
         
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:harryi3t,项目名称:Save-The-Ball,代码行数:22,代码来源:Score.java

示例4: loadDefinition

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Load the definition file and parse each of the sections
 *
 * @param def The location of the definitions file
 * @param trans The color to be treated as transparent
 * @throws SlickException Indicates a failure to read or parse the definitions file
 * or referenced image.
 */
private void loadDefinition(String def, @Nullable Color trans) throws SlickException {
    try (
            final InputStream resourceAsStream = ResourceLoader.getResourceAsStream(def);
            final Reader inputStreamReader = new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8);
            final BufferedReader reader = new BufferedReader(inputStreamReader)) {
        image = new Image(basePath+reader.readLine(), false, filter, trans);
        while (reader.ready()) {
            if (reader.readLine() == null) {
                break;
            }

            Section sect = new Section(reader);
            sections.put(sect.name, sect);

            if (reader.readLine() == null) {
                break;
            }
        }
    } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Failed to process definitions file - invalid format?", e);
    }
}
 
开发者ID:FOShameDotOrg,项目名称:fuzzy-octo-shame,代码行数:32,代码来源:PackedSpriteSheet.java

示例5: loadTextureLinear

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public static int loadTextureLinear(String filename){
    int texture = glGenTextures();
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
    InputStream in;
    try {
        in = ResourceLoader.getResourceAsStream("res/textures/"+filename);
        PNGDecoder decoder = new PNGDecoder(in);
        ByteBuffer buffer = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buffer, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
        buffer.flip();
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
    } catch (IOException e) {
        e.printStackTrace();
    }
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);

    return texture;
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:21,代码来源:GameResourceLoader.java

示例6: loadShader

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public static String loadShader(String filename){
    StringBuilder shaderSource = new StringBuilder();
    BufferedReader shaderReader = null;

    try {
        shaderReader = new BufferedReader(new InputStreamReader(ResourceLoader.getResourceAsStream("res/shaders/" + filename)));
        String line;
        while ((line = shaderReader.readLine()) != null){
            shaderSource.append(line).append("\n");
        }

        shaderReader.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return shaderSource.toString();
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:19,代码来源:GameResourceLoader.java

示例7: getProgramCode

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Gets the program code from the file <tt>filename</tt> and puts it into a
 * <tt>ByteBuffer</tt>.
 *
 * @param filename
 *            the full name of the file.
 * @return a ByteBuffer containing the program code.
 * @throws SlickException
 */
private ByteBuffer getProgramCode(String filename) throws SlickException {
    InputStream fileInputStream;
    byte[] shaderCode;

    fileInputStream = ResourceLoader.getResourceAsStream(filename);
    DataInputStream dataStream = new DataInputStream(fileInputStream);
    try {
        dataStream.readFully(shaderCode = new byte[fileInputStream.available()]);
        fileInputStream.close();
        dataStream.close();
    } catch (IOException e) {
        throw new SlickException(e.getMessage());
    }

    ByteBuffer shaderPro = BufferUtils.createByteBuffer(shaderCode.length);

    shaderPro.put(shaderCode);
    shaderPro.flip();

    return shaderPro;
}
 
开发者ID:Pheelbert,项目名称:cretion,代码行数:31,代码来源:ShaderManagerImpl.java

示例8: loadBitmapFonts

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Load bitmap fonts.
 */
public static void loadBitmapFonts() {
	Scanner in = new Scanner(ResourceLoader.getResourceAsStream("res/fonts/fonts.txt"));
	while(in.hasNextLine()) {
		String line = in.nextLine();
		if(line.startsWith("#"))
			continue;
		if(line.startsWith("define")) {
			String name = line.split(":")[1];
			String texName = in.nextLine();
			char[] chars = in.nextLine().toCharArray();
			int height = Integer.parseInt(in.nextLine());
			int spacing = Integer.parseInt(in.nextLine());
			char[] widths = in.nextLine().toCharArray();
			
			BitmapFont font = new BitmapFont(texName);
			font.setHeight(height);
			font.setSpacing(spacing);
			int pos = 0;
			for(int i=0; i<chars.length; i++) {
				int width = Integer.parseInt(widths[i]+"");
				font.put(chars[i], pos, width);
				pos += width;
			}
			bitmapFonts.put(name, font);
			System.out.println(name+"(bitmap font) loaded");
		}
	}
	in.close();
}
 
开发者ID:eliatlarge,项目名称:FEMultiPlayer-V2,代码行数:33,代码来源:FEResources.java

示例9: load

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Carrega os dados do arquivo.
 */
private void load() throws SlickException {
	InputStream is = ResourceLoader.getResourceAsStream(this.path);
	BufferedReader input = new BufferedReader(new InputStreamReader(is));
	
	String line = null;	
	int i = 0;
	try {
		while ((line = input.readLine()) != null){
			if (line.trim().equals("tiles [")) { 					
				currentArea = 0;
				continue;
			} else if (line.trim().equals("]")) {
				continue;
			}
			
			switch (currentArea) {
				case 0: //tiles
					this.parseTileData(line, i++);
					break;
			}
		}
		
		input.close();
	} catch (IOException e) { 
		e.printStackTrace();
	}
}
 
开发者ID:intentor,项目名称:telyn,代码行数:31,代码来源:LayerConfiguration.java

示例10: loadDefinition

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Carrega o arquivo de defini��o e cria as se��es.
 * @param def 	Caminho do arquivo de defini��o.
 * @param trans Cor a ser tratada como transpar�ncia.
 */
private void loadDefinition(String def, Color trans) throws SlickException {
	BufferedReader reader = new BufferedReader(new InputStreamReader(ResourceLoader.getResourceAsStream(def)));

	try {
		image = new Image(basePath + reader.readLine(), false, filter, trans);
		while (reader.ready()) {
			if (reader.readLine() == null) break;
			this.sections.add(new PackedSpriteSection(reader, this.image));				
			if (reader.readLine() == null) break;
		}
	} catch (Exception e) {
		throw new SlickException("Falha no processamento do arquivo de defini��o. Talvez o formato seja inv�lido?", e);
	}
}
 
开发者ID:intentor,项目名称:telyn,代码行数:20,代码来源:PackedSpriteSheet.java

示例11: LoadTexture

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public static Texture LoadTexture(String path, String fileType) {
	Texture tex = null;
	InputStream in = ResourceLoader.getResourceAsStream(path);
	try {
		tex = TextureLoader.getTexture(fileType, in);
	}
	catch (IOException e) {
		e.printStackTrace();
	}
	return tex;
}
 
开发者ID:massm039,项目名称:SRPG,代码行数:12,代码来源:Artist.java

示例12: LoadPNG

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public static Texture LoadPNG(String fileName) {
	Texture tex = null;
	InputStream in = ResourceLoader.getResourceAsStream("res/" + fileName + ".png");
	try {
		tex = TextureLoader.getTexture("PNG", in);
	}
	catch (IOException e) {
		e.printStackTrace();
	}
	return tex;
}
 
开发者ID:massm039,项目名称:SRPG,代码行数:12,代码来源:Artist.java

示例13: TextBox

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public TextBox(String font) {
	try {
		InputStream inputStream = ResourceLoader.getResourceAsStream(font);
		Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
		awtFont = awtFont.deriveFont(32f); //font size
		this.font = new TrueTypeFont(awtFont, false);
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:massm039,项目名称:SRPG,代码行数:12,代码来源:TextBox.java

示例14: changeFont

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
public void changeFont(String font) {
	try {
		InputStream inputStream = ResourceLoader.getResourceAsStream(font);
		Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
		awtFont = awtFont.deriveFont(32f); //font size
		this.font = new TrueTypeFont(awtFont, false);
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:massm039,项目名称:SRPG,代码行数:12,代码来源:TextBox.java

示例15: LoadTexture

import org.newdawn.slick.util.ResourceLoader; //导入方法依赖的package包/类
/**
 * Método para crear una texura
 * 
 * @param path Path de la textura
 * @param fileType Tipo de la textura
 * @return Textura
 * 
 * @author Alba Ríos
 */
public static Texture LoadTexture(String path, String fileType){
    System.out.println( System.getProperty("user.dir"));
    Texture tex = null;
    InputStream in = ResourceLoader.getResourceAsStream(path);
    try {
        tex = TextureLoader.getTexture(fileType, in);
    } catch (IOException ex) {
        Logger.getLogger(Artist.class.getName()).log(Level.SEVERE, null, ex);
    }
    return tex;
}
 
开发者ID:Trifido,项目名称:star-droids,代码行数:21,代码来源:Artist.java


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