1、button的创建

首先我们创建一个空节点
再右键空节点我们选择UI节点–button按钮
cocoscreator入门(界面UI)--button的使用
通过 层级管理器 菜单创建的 Button 节点,由带有 Button 组件的父节点和一个带有 Label 组件的子节点组成。Button 父节点提供交互功能和按钮背景图显示,Label 子节点提供按钮上标签文字的渲染。
您可以根据美术风格和设计需要,将 Label 节点删除或者替换成需要的其他图标 Sprite。cocoscreator入门(界面UI)--button的使用
通常我们在设置按钮位置时通过主体控件来修改位置。
因为带有 Button 组件的父节点和一个带有 Label 组件的子节点组成,若是你只调节background 的话,Lable标签不会跟着移动。

2、button组件属性

我们打开button的属性检查器发现它由两部分组成

cocoscreator入门(界面UI)--button的使用

Node属性

button属性–

cocoscreator入门(界面UI)--button的使用
其中我们常用的是Transitionclickevents
Transition有四个属性

NONE

COLOR ——可设置button不同情况下的颜色

cocoscreator入门(界面UI)--button的使用

Sprite Transition——button不同情况下的图片显示

cocoscreator入门(界面UI)--button的使用

Scale Transition

cocoscreator入门(界面UI)--button的使用

Button 点击事件

cocoscreator入门(界面UI)--button的使用

相关文章: