在cocos2d-js中可以用添加Menu的方式来添加各种可以交互的东西,比如图片,文字等
但是如果按钮位置分布不均衡的时候,使用Menu给我的感觉反而不是很方便,所以在寻找更便捷的方式。
然后我觉得cocos自带例子中的ccui.Button是我比较喜欢的方式,于是定义如下:
var Button = new ccui.Button();
Button.setTouchEnabled(true);
Button.setPressedActionEnabled(true);
Button.loadTextures("res/buttons.png","res/buttons.png","");
Button.x = 135;
Button.y = 240;
Button.addTouchEventListener(this.selected,this);
this.addChild(Button);
cocos js添加 按钮1
最新推荐文章于 2024-05-14 01:29:06 发布