cc.Class({
extends: cc.Component,
properties: {
resetBtn:
{
default:null,
type:cc.Button,
},
addBtn:
{
default:null,
type:cc.Button,
},
subBtn:
{
default:null,
type:cc.Button,
},
rideBtn:
{
default:null,
type:cc.Button,
},
divisionBtn:
{
default:null,
type:cc.Button,
},
leftBtn:
{
default:null,
type:cc.Button,
},
rightBtn:
{
default:null,
type:cc.Button,
},
backBtn:
{
default:null,
type:cc.Button,
},
okBtn:
{
default:null,
type:cc.Button,
},
answerTxt:
{
default:null,
type:cc.Label,
}
},
// use this for initialization
onLoad: function () {
for(var i=1;i<=4;i++)
{
this'card'+i]=this.node.getChildByName("card"+i);
this'card'+i]=this'card'+i].getComponent('Card');
this'card'+i].setNum(i);
}
this.resetBtn.getComponent(cc.Button).node.on(cc.Node.EventType.MOUSE_DOWN,this.clickBtn);
this.test();
},
test:function()
{
alert(this.resetBtn)
},
clickBtn:function(event)
{
alert(this.resetBtn)
// switch(event.currentTarget)
// {
// case this.resetBtn.getComponent(cc.Button).node:
// alert("re");
// break;
// }
}
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
输出的resetBtn竟然是null,但是在onLoad中却能得到对象不为空,这是为什么?