Here you can find the source of getResource(String fileName, int type)
Parameter | Description |
---|---|
fileName | The name of the requested resource, without file ending. |
type | The resource type (ResourceHelper.RES_XXX). |
public static File getResource(String fileName, int type)
//package com.java2s; /*//from w w w .j a v a 2 s .c o m * Copyright (c) 2014 mgamelabs * To see our full license terms, please visit https://github.com/mgamelabs/mengine/blob/master/LICENSE.md * All rights reserved. */ import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static final int RES_PREFERENCE = 2; public static final int RES_SAVE = 3; public static final int RES_MATERIAL = 4; public static final int RES_MODEL = 5; public static final int RES_SOUND = 6; public static final int RES_TEXTURE = 7; public static final int RES_TEXTURE_ANIMATED = 8; public static final int RES_SHADER_V = 9; public static final int RES_SHADER_F = 10; private static List<String> paths = new ArrayList<String>(); /** * Returns a game resource. * * @param fileName The name of the requested resource, without file ending. * @param type The resource type (ResourceHelper.RES_XXX). * @return The requested resource file. */ public static File getResource(String fileName, int type) { String filePath; switch (type) { default: filePath = paths.get(type) + fileName; break; case RES_PREFERENCE: filePath = paths.get(type) + fileName + ".properties"; break; case RES_SAVE: filePath = paths.get(type) + fileName + ".mess"; break; case RES_MATERIAL: filePath = paths.get(type) + fileName + ".mtl"; break; case RES_MODEL: filePath = paths.get(type) + fileName + ".obj"; break; case RES_SOUND: filePath = paths.get(type) + fileName + ".wav"; break; case RES_TEXTURE: filePath = paths.get(type) + fileName + ".png"; break; case RES_TEXTURE_ANIMATED: filePath = paths.get(type) + fileName + ".meta"; break; case RES_SHADER_V: filePath = paths.get(type) + fileName + ".vs"; break; case RES_SHADER_F: filePath = paths.get(type) + fileName + ".fs"; break; } return new File(filePath); } }