mirror of https://github.com/axmolengine/axmol.git
button Opacity setting
This commit is contained in:
parent
149775ea10
commit
03e5573f79
|
@ -24,6 +24,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
var UIButtonTest = UIMainLayer.extend({
|
var UIButtonTest = UIMainLayer.extend({
|
||||||
|
_button:null,
|
||||||
init: function () {
|
init: function () {
|
||||||
if (this._super()) {
|
if (this._super()) {
|
||||||
//init text
|
//init text
|
||||||
|
@ -32,7 +33,7 @@ var UIButtonTest = UIMainLayer.extend({
|
||||||
|
|
||||||
var widgetSize = this._widget.getContentSize();
|
var widgetSize = this._widget.getContentSize();
|
||||||
// Create the button
|
// Create the button
|
||||||
var button = new ccui.Button();
|
var button = this._button = new ccui.Button();
|
||||||
button.setTouchEnabled(true);
|
button.setTouchEnabled(true);
|
||||||
button.loadTextures("ccs-res/cocosui/animationbuttonnormal.png", "ccs-res/cocosui/animationbuttonpressed.png", "");
|
button.loadTextures("ccs-res/cocosui/animationbuttonnormal.png", "ccs-res/cocosui/animationbuttonpressed.png", "");
|
||||||
button.x = widgetSize.width / 2.0;
|
button.x = widgetSize.width / 2.0;
|
||||||
|
@ -40,11 +41,23 @@ var UIButtonTest = UIMainLayer.extend({
|
||||||
button.addTouchEventListener(this.touchEvent, this);
|
button.addTouchEventListener(this.touchEvent, this);
|
||||||
this._mainNode.addChild(button);
|
this._mainNode.addChild(button);
|
||||||
|
|
||||||
|
var label = new cc.LabelTTF("setOpacity", "Arial", 25);
|
||||||
|
var menuItem = new cc.MenuItemLabel(label,this.setOpacityTest,this);
|
||||||
|
var menu = new cc.Menu(menuItem);
|
||||||
|
menu.x = 0;
|
||||||
|
menu.y = 0;
|
||||||
|
menuItem.x = widgetSize.width-100;
|
||||||
|
menuItem.y = 270;
|
||||||
|
this._mainNode.addChild(menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
setOpacityTest:function(){
|
||||||
|
var button = this._button;
|
||||||
|
var opacity = (button._realOpacity===255? 100:255);
|
||||||
|
button.setOpacity(opacity);
|
||||||
|
},
|
||||||
touchEvent: function (sender, type) {
|
touchEvent: function (sender, type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ccui.Widget.TOUCH_BEGAN:
|
case ccui.Widget.TOUCH_BEGAN:
|
||||||
|
|
Loading…
Reference in New Issue