Package com.teamjmonkey.graphics

Source Code of com.teamjmonkey.graphics.GraphicManager

package com.teamjmonkey.graphics;

import com.jme3.asset.AssetManager;
import com.jme3.scene.Spatial;
import com.teamjmonkey.GameNameGoesHere;
import com.teamjmonkey.util.Manager;
import com.teamjmonkey.util.PreloadManager;
import java.util.EnumMap;

public class GraphicManager implements Manager {

    private GameNameGoesHere myApp = GameNameGoesHere.getApp();
    private AssetManager assetManager = myApp.getAssetManager();
    private EnumMap<Graphics, Spatial> graphicMap = new EnumMap<Graphics, Spatial>(Graphics.class);
    private PreloadManager preloadManager = myApp.getPreloadManager();

    public void load(int level) {
        //load all needed graphics
        if (level == 1) {
            loadGraphics(new Graphics[]{Graphics.TEST_PLATFORM});
        } else if (level == 2) {
            loadGraphics(new Graphics[]{Graphics.TEST_PLATFORM});
        }
    }

    private void loadGraphics(Graphics[] graphics) {
        for (Graphics graphic : graphics) {
            Spatial s = createSpatial(graphic);
            preloadManager.preload(s);
            graphicMap.put(graphic, s);
        }
    }

    public Spatial createSpatial(Graphics graphic) {
        return assetManager.loadModel(graphic.getPath());
    }

    public void cleanup() {
        graphicMap.clear();
    }
}
TOP

Related Classes of com.teamjmonkey.graphics.GraphicManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.