0

嗨,我正在使用 cocos2d 做一个应用程序,这里我需要显示编辑文本。我很容易显示图像和文本视图,但我不知道如何显示编辑文本。如果有人对 cocos2d 中的 edittext 有任何想法,请建议我...使用下面的代码我显示图​​像..

    HelloWorldLayer:

  public class HelloWorldLayer extends CCColorLayer {
  static HelloWorldLayer layer;
    CGSize winSize;
   CCSprite home,target;
protected HelloWorldLayer(ccColor4B color) {
    super(color);
    // TODO Auto-generated constructor stub
     winSize = CCDirector.sharedDirector().displaySize();
     this.setIsTouchEnabled(true);
    home= CCSprite.sprite("banana.png");
    home.setPosition(winSize.width/2,winSize.height/2);
    this.addChild(home);
    }

       public static CCScene scene() {
    // TODO Auto-generated method stub
     //Creates scene  
    CCScene scene = CCScene.node();


     layer = new HelloWorldLayer(ccColor4B.ccc4(225, 225,225, 225));

    //adds layer to scene
    scene.addChild(layer);

    return scene;
}



@Override
public boolean ccTouchesEnded(MotionEvent event)
{
    CGPoint location = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY()));

    if (CGRect.containsPoint(home.getBoundingBox(), location))
    { 

         CCDirector.sharedDirector().replaceScene(CCFadeTransition.transition(0.5f,GamestartLayer.scene()));
            removeAllChildren(true);  

    }

            return true;
}


 }
4

1 回答 1

0

您可以在 cocos2d 游戏活动中动态添加 UI 视图

    EditText txv=new EditText(context);
    txv.setText("ABC");
    CCDirector.sharedDirector().getActivity().addContentView(txv,layoutParams);
于 2012-12-20T15:01:39.117 回答