Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Pedroalves

pegar e legar um item

Recommended Posts

não estou a conseguir por a funcionar o pegar e lagar

segue-se o codigo

 

package mygame.menus;

import org.slf4j.*;

import com.jme3.app.Application;
import com.jme3.app.state.BaseAppState;
import com.jme3.math.*;
import com.jme3.scene.*;

import com.simsilica.lemur.*;
import com.simsilica.lemur.component.QuadBackgroundComponent;

import com.simsilica.lemur.grid.ArrayGridModel;
import com.simsilica.lemur.input.InputMapper;
import com.simsilica.lemur.style.ElementId;
import mygame.Main;
import mygame.MainGameFunctions;
import mygame.MainMenuState;
import mygame.panels.CustomGridPanel;

/**
 *
 *
 * @author Pedro Alves
 */
public class InventoryMenuState extends BaseAppState {

    static Logger log = LoggerFactory.getLogger(InventoryMenuState.class);

    private Container mainWindow;

    //private Container sessionButtons;
    public InventoryMenuState(boolean enabled) {
        setEnabled(enabled);

    }

    /**
     * Returns the tabbed panel used in the in-game menu. This lets other states
     * potentially add their own in-game menu tabs.
     *
     * @return
     */
    /* public TabbedPanel getTabs() {
        return tabs;
    }

    public List<Action> getSessionActions() {
        return sessionActions;
    }
     */
    public void toggleEnabled() {
        setEnabled(!isEnabled());
    }

    @Override
    protected void initialize(Application app) {
        mainWindow = new Container();

        // mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        Label o = mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        o.setFontSize(12);
        o.setPreferredSize(new Vector3f(50, 25, 0));
        o.setTextHAlignment(HAlignment.Center);
        Label f = mainWindow.addChild(new Label("Default Cube", new ElementId("title")));
        f.setTextHAlignment(HAlignment.Center);
        f.setFontSize(12);
        f.setPreferredSize(new Vector3f(50, 25, 0));
        Panel[][] data = new Panel[4][8];
        Panel[][] data1 = new Panel[4][8];
        Label slot1 = new Label("1");
        Label slot2 = new Label("2");
        Label slot3 = new Label("3");
        Label slot4 = new Label("4");
        Label slot5 = new Label("5");
        Label slot6 = new Label("6");
        Label slot7 = new Label("7");
        Label slot8 = new Label("8");
        Label slot9 = new Label("1");
        Label slot10 = new Label("2");
        Label slot11 = new Label("3");
        Label slot12 = new Label("4");
        Label slot13 = new Label("5");
        Label slot14 = new Label("6");
        Label slot15 = new Label("7");
        Label slot16 = new Label("8");
        Label slot17 = new Label("1");
        Label slot18 = new Label("2");
        Label slot19 = new Label("3");
        Label slot20 = new Label("4");
        Label slot21 = new Label("5");
        Label slot22 = new Label("6");
        Label slot23 = new Label("7");
        Label slot24 = new Label("8");
        Label slot25 = new Label("1");
        Label slot26 = new Label("2");
        Label slot27 = new Label("3");
        Label slot28 = new Label("4");
        Label slot29 = new Label("5");
        Label slot30 = new Label("6");
        Label slot31 = new Label("7");
        Label slot32 = new Label("8");
        Label slot33 = new Label("1");
        Label slot34 = new Label("2");
        Label slot35 = new Label("3");
        Label slot36 = new Label("4");
        Label slot37 = new Label("5");
        Label slot38 = new Label("6");
        Label slot39 = new Label("7");
        Label slot40 = new Label("8");
        Label slot41 = new Label("1");
        Label slot42 = new Label("2");
        Label slot43 = new Label("3");
        Label slot44 = new Label("4");
        Label slot45 = new Label("5");
        Label slot46 = new Label("6");
        Label slot47 = new Label("7");
        Label slot48 = new Label("8");
        Label slot49 = new Label("1");
        Label slot50 = new Label("2");
        Label slot51 = new Label("3");
        Label slot52 = new Label("4");
        Label slot53 = new Label("5");
        Label slot54 = new Label("6");
        Label slot55 = new Label("7");
        Label slot56 = new Label("8");
         Label slot57 = new Label("1");
        Label slot58 = new Label("2");
        Label slot59 = new Label("3");
        Label slot60 = new Label("4");
        Label slot61 = new Label("5");
        Label slot62 = new Label("6");
        Label slot63 = new Label("7");
        Label slot64 = new Label("8");
        
        slot2.setPreferredSize(new Vector3f(50, 25, 0));
        slot3.setPreferredSize(new Vector3f(50, 25, 0));
        slot4.setPreferredSize(new Vector3f(50, 25, 0));
        slot5.setPreferredSize(new Vector3f(50, 25, 0));
        slot6.setPreferredSize(new Vector3f(50, 25, 0));
        slot7.setPreferredSize(new Vector3f(50, 25, 0));
        slot8.setPreferredSize(new Vector3f(50, 25, 0));

        data[0][0] = slot1;
        data[0][1] = slot2;
        data[0][2] = slot3;
        data[0][3] = slot4;
        data[0][4] = slot5;
        data[0][5] = slot6;
        data[0][6] = slot7;
        data[0][7] = slot8;
        data[1][0] = slot9;
        data[1][1] = slot10;
        data[1][2] = slot11;
        data[1][3] = slot12;
        data[1][4] = slot13;
        data[1][5] = slot14;
        data[1][6] = slot15;
        data[1][7] = slot16;
        data[2][0] = slot17;
        data[2][1] = slot18;
        data[2][2] = slot19;
        data[2][3] = slot20;
        data[2][4] = slot21;
        data[2][5] = slot22;
        data[2][6] = slot23;
        data[2][7] = slot24;
        data[3][0] = slot25;
        data[3][1] = slot26;
        data[3][2] = slot27;
        data[3][3] = slot28;
        data[3][4] = slot29;
        data[3][5] = slot30;
        data[3][6] = slot31;
        data[3][7] = slot32;

        CustomGridPanel ola = new CustomGridPanel(new ArrayGridModel<>(data));
ola.getModel().setCell(3, 7, data[3][7]);
ola.setVisibleRows(4);

ola.setVisibleColumns(8);
  ola.setInsets(new Insets3f(10, 10, 0, 10));
        System.err.println(""+ola.getModel().getColumnCount());
          System.err.println(""+ola.getModel().getRowCount());
//ola.setPreferredSize(new Vector3f(400, 400, 0));

        mainWindow.addChild(ola);
        // ola.setPreferredSize(new Vector3f(25, 350, 0));

        mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        data1[0][0] = slot33;
        data1[0][1] = slot34;
        data1[0][2] = slot35;
        data1[0][3] = slot36;
        data1[0][4] = slot37;
        data1[0][5] = slot38;
        data1[0][6] = slot39;
        data1[0][7] = slot40;
        data1[1][0] = slot41;
        data1[1][1] = slot42;
        data1[1][2] = slot43;
        data1[1][3] = slot44;
        data1[1][4] = slot45;
        data1[1][5] = slot46;
        data1[1][6] = slot47;
        data1[1][7] = slot48;
        data1[2][0] = slot49;
        data1[2][1] = slot50;
        data1[2][2] = slot51;
        data1[2][3] = slot52;
        data1[2][4] = slot53;
        data1[2][5] = slot54;
        data1[2][6] = slot55;
        data1[2][7] = slot56;
        data1[3][0] = slot57;
        data1[3][1] = slot58;
        data1[3][2] = slot59;
        data1[3][3] = slot60;
        data1[3][4] = slot61;
        data1[3][5] = slot62;
        data1[3][6] = slot63;
        data1[3][7] = slot64;
        Container loginPanel=mainWindow.addChild(new Container());
       GridPanel maria = new GridPanel(new ArrayGridModel<>(data1));
        loginPanel.addChild(maria);
       maria.setVisibleRows(4);
maria.setVisibleColumns(8);
        mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        mainWindow.addChild(new Label("Inventory", new ElementId("title")));
        mainWindow.addChild(new Label("Inventory", new ElementId("title")));

        mainWindow.setPreferredSize(new Vector3f(350, 450, 0));
        int height = app.getCamera().getHeight();
        Vector3f pref = mainWindow.getPreferredSize().clone();

        float standardScale = getState(MainMenuState.class).getStandardScale();
        pref.multLocal(1.5f * standardScale);

        // With a slight bias toward the top        
        float y = height * 0.9f + pref.y * 0.0f;

        mainWindow.setLocalTranslation(250 * standardScale, y, 0);

        InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper();
        inputMapper.addDelegate(MainGameFunctions.F_IN_GAME_INVENTORY, this, "toggleEnabled");
    }

    @Override
    protected void cleanup(Application app) {

        InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper();
        inputMapper.removeDelegate(MainGameFunctions.F_IN_GAME_INVENTORY, this, "toggleEnabled");
    }

    @Override
    protected void onEnable() {
        Node gui = ((Main) getApplication()).getGuiNode();
        gui.attachChild(mainWindow);
    }

    @Override
    protected void onDisable() {
        mainWindow.removeFromParent();
    }
    
}

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por violin101
      Caros amigos, saudações.
       
      Estou escrevendo um Sistema Java Web e quando clico no Botão Salvar, o Java acusa esse erro:

      ERROR: Cannot invoke "Object.toString()" because the return value of "java.util.Map.get(Object)" is null
       
      Já tentei de várias formas resolver esse problema, mas não estou conseguindo.

      Por favor, alguém pode me ajudar identificar a origem e resolver o problema acima ?

      Grato,
       
      Cesar
    • Por violin101
      Caros amigos, saudações.

      Estou enfrentando um problema que não consigo entender.

      Após Instalar o MySql versão 8.0.36, funciona corretamente realizando as conexões.

      O problema é:
      ---[ após reiniciar o micro, o MySql não faz as conexões.
      --[ tenta localizar este arquivo, mas não acha: my.ini
       
      Onde localizo ou configuro este arquivo na Pasta MySql ?

      Grato,
       
      Cesar
    • Por violin101
      Caros amigos, saudações.
       
      Por favor, preciso de ajuda em Relação a Instalar o Jasper Reports no Eclipse, pois a opção de Eclipse Marketplace, não encontra para instalar.
       
      Já tentei de todas as formas mas não consegui, alguém conhece alguma rotina explicando este procedimento ?
       
      Grato,
       
      Cesar
    • Por violin101
      Caros amantes da informática.
       
      Saudações.
       
      Estou usando o Eclipse Mars versão 4.5.0  e o 4.5.2, acredito que deva ter versões mais novas. 
      Sou novato em JAVA e estou encontrando alguns problema em Instalação de alguns plugins, como por exemplo:
       
      1) quando tento instalar o JBoss Tools através do Eclipse Marteplace, o Eclipse não o encontra na lista de plugins.
      2) se tento instalar através do Install New Software, abaixa alguns arquivos, mas também não instala o JBoss.
      3) se abro o site e arrasto o download para a área de trabalho do Eclipse, também não instala o JBoss.
       
      Caros amigos, existe outra alguma forma de instalar o JBoss Tools no Eclipse e como seria ?
       
      Grato,
       
      Cesar
       
       
    • Por ILR master
      Pessoal, pergunta bem simples. Abaixo tenho o seguinte código:
       
      <script>
      function alerta()
      {
        if (window.confirm("Você realmente quer sair?")) {
          window.open("sair.html");
      }
      }
      </script>
       
      Funciona perfeitamente, só que está abrindo em outra janela e quero que abra na mesma janela.
       
      Alguém pode me ajudar?
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.