欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Java 屏幕类使用示例

最编程 2024-07-09 21:20:05
...

实例1: onMouseMove

import tonegod.gui.core.Screen; //导入依赖的package包/类
@Override
public void onMouseMove(MouseMotionEvent evt) {
	if (!Screen.isAndroid()) {
		float x = evt.getX()-getX();
		float y = scrollableArea.getAbsoluteHeight()-menuPadding.z-evt.getY();

		if (currentMenuItemIndex != (int)Math.floor(y/menuItemHeight)) {
			currentMenuItemIndex = (int)Math.floor(y/menuItemHeight);

			if (currentMenuItemIndex > -1 && currentMenuItemIndex < menuItems.size()) {
				setHighlight(currentMenuItemIndex);
				this.hideAllSubmenus(false);
				Menu subMenu = menuItems.get(currentMenuItemIndex).getSubMenu();
				if (subMenu != null) {
					subMenu.showMenu(this, getAbsoluteWidth()-this.menuOverhang, scrollableArea.getAbsoluteHeight()-(menuItemHeight+(currentMenuItemIndex*menuItemHeight))-(subMenu.getHeight()-menuItemHeight));
				}
			}
		}
	}
}
 

实例2: EmitterModule

import tonegod.gui.core.Screen; //导入依赖的package包/类
public EmitterModule(final SimpleApplication app) {
        super(app.getAssetManager().loadTexture("org/hexgridapi/assets/Textures/"
                + "Icons/Buttons/hexIconBW.png").getImage(),
                "Emitter Module", null, false);
        this.app = app;
        //@todo need to be cleanned
//        app.getAssetManager().registerLocator("/home/roah/Documents/jmonkey/3.1/tonegodProjects/EmitterBuilder/assets", FileLocator.class);
        screen = new Screen(app, "tonegod/gui/style/atlasdef/style_map.gui.xml");
        screen.setUseTextureAtlas(true, "tonegod/gui/style/atlasdef/atlas.png");
//        screen.setUseCustomCursors(true);
        
        builder = new EmitterBuilder(app, screen);
        chaseCam = new ChaseCamera(app.getCamera(), builder.getRootNode(), app.getInputManager());
        app.enqueue(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                if(app.getGuiNode().getControl(Screen.class) == null)
                    app.getGuiNode().addControl(screen);
                return null;
            }
        });
    }
 

实例3: initApp

import tonegod.gui.core.Screen; //导入依赖的package包/类
@Override
    public void initApp() {
        // initialise hexgrid
        RTSCamera.KeyMapping keyMapping = RTSCamera.KeyMapping.col;
        screen = new Screen(this);
        getGuiNode().addControl(screen);
        rtsCam = new RTSCamera(keyMapping);
        MapData mapData = new MapData(assetManager, new String[]{"EARTH", "ICE", "NATURE", "VOLT"});
        hexGridState = new HexGridAppState(mapData, rtsCam, "org/hexgridapi/assets/Textures/HexField/");
        rootNode.attachChild(hexGridState.getGridNode());
        
        MapParam param = new MapParam(SquareCoordinate.class, new Vector2Int(3, 4),
                7, 1, false, false, 722093121, null);
        hexGridState.setParam(param);
        
//        EntityDataAppState entityDataAppState = new EntityDataAppState();
//        stateManager.attachAll(rtsCam, hexGridState, entityDataAppState,
//                new RenderSystem(), new HexPositionSystem(), 
//                new RenderDebugSystem(), new BattleSystemTest());
        stateManager.attachAll(rtsCam, hexGridState, 
                new MultiverseCoreState(keyMapping, BattleSystemTest.class));

        setDisplayFps(false);
        setDisplayStatView(false);
    }
 

实例4: StaminaGauge

import tonegod.gui.core.Screen; //导入依赖的package包/类
public StaminaGauge(Screen screen, String filePath, Vector2f position) {

        gauge = new Indicator(screen, position, new Vector2f(300, 15),
                new Vector4f(5, 50, 50, 5), filePath + "skill.png", Element.Orientation.HORIZONTAL) {
                    @Override
                    public void onChange(float currentValue, float currentPercentage) {
                    }
                };
        ((Indicator)gauge).setIndicatorColor(ATBGauge.getColor("Blue"));
        ((Indicator)gauge).setAlphaMap(filePath + "skillAlpha.png");

        ((Indicator)gauge).setOverlayImage(filePath + "skillOverlay.png");
        ((Indicator)gauge).setBaseImage(filePath + "skill.png");

        ((Indicator)gauge).setMaxValue(100);
    }
 

实例5: LayoutParser

import tonegod.gui.core.Screen; //导入依赖的package包/类
public LayoutParser(Screen screen) {
        this.screen = screen;
        
        
        controls.add(OSRViewPort.class);
        controls.add(Indicator.class);
        controls.add(Slider.class);
        controls.add(Dial.class);
        controls.add(CheckBox.class);
        controls.add(RadioButton.class);
        controls.add(Button.class);
        controls.add(ChatBox.class);
        controls.add(ChatBoxExt.class);
        controls.add(Panel.class);
        controls.add(ColorWheel.class);
        controls.add(LoginBox.class);
        controls.add(AlertBox.class);
        controls.add(DialogBox.class);
        controls.add(Window.class);
        controls.add(TabControl.class);
        controls.add(SelectBox.class);
        controls.add(ComboBox.class);
        controls.add(Menu.class);
        controls.add(SelectList.class);
        controls.add(ScrollArea.class);
        controls.add(SlideTray.class);
        controls.add(Spinner.class);
        controls.add(Label.class);
        controls.add(Password.class);
        controls.add(TextField.class);
}
 

推荐阅读