示例#1
0
    public MyLayer() {
      // add label
      WYSize s = Director.getInstance().getWindowSize();
      Label label = Label.make("", 22, "DroidSans", Typeface.BOLD, 0);
      label.setColor(new WYColor3B(0, 0, 0));

      // sprite for button
      NinePatchSprite normal =
          NinePatchSprite.make(
              Texture2D.makePNG(R.drawable.textbox_normal),
              ResolutionIndependent.resolve(WYRect.make(11, 21, 1, 1)));
      NinePatchSprite pressed =
          NinePatchSprite.make(
              Texture2D.makePNG(R.drawable.textbox_pressed),
              ResolutionIndependent.resolve(WYRect.make(11, 21, 1, 1)));
      NinePatchSprite focused =
          NinePatchSprite.make(
              Texture2D.makePNG(R.drawable.textbox_focused),
              ResolutionIndependent.resolve(WYRect.make(11, 21, 1, 1)));
      normal.setContentSize(DP(280), DP(42));
      pressed.setContentSize(DP(280), DP(42));
      focused.setContentSize(DP(280), DP(42));

      // 通过addContentView添加一个EditText到场景中,它实际上是盖在WYGLSurfaceView上面
      TextBox box = TextBox.make(normal, pressed, null, focused, label);
      box.setPosition(s.width / 2, s.height / 2);
      box.setTitle("Input something!");
      box.setMessage("试试中文的提示怎么样");
      box.setPositiveButton("想修改就点我");
      box.setNegativeButton("Oh No!");
      box.setPadding(DP(10), DP(3), DP(10), DP(6));
      box.setCallback(this);
      addChild(box);
    }
示例#2
0
    public MyLayer() {
      Texture2D tex1 = Texture2D.make(R.drawable.ortho_test1);
      tex1.autoRelease();
      Texture2D tex2 = Texture2D.make(R.drawable.ortho_test1_bw);
      tex2.autoRelease();
      mMap = TMXTileMap.make(R.raw.orthogonal_test5, tex1, tex2);
      addChild(mMap);

      // add click feedback sprite
      Texture2D tex = Texture2D.make(R.drawable.blocks);
      mSprite = Sprite.make(tex, ResolutionIndependent.resolve(WYRect.make(0, 0, 32, 32)));
      mSprite.setVisible(false);
      mMap.addChild(mSprite, 10);

      // add a hint label
      WYSize s = Director.getInstance().getWindowSize();
      Label label = Label.make("(Menu)Switch Clip", 16);
      label.setPosition(s.width / 2, s.height - 30);
      addChild(label);

      setTouchEnabled(true);
      setKeyEnabled(true);
      setJavaVirtualMethods(this);
    }
示例#3
0
 private float DP(float v) {
   return ResolutionIndependent.resolveDp(v);
 }