I have created more than one Button all having the same function, But the problem i could not identify which one was pressed.
Please advice
I have created more than one Button all having the same function, But the problem i could not identify which one was pressed.
Please advice
hideho
if you add an event parameter to the function you call, you can access the individual buttons nodes and, for example, the buttons labels string:
testEvent:function(event){
var btnLblStr=event.target.getChildByName("Label").getComponent(cc.Label).string;
},
cheers
Thanks very much it worked
Hi @malbishtawi,
if I may recommend, there is a more elegant solution. The cc.Button click event has a CustomEventData property:
And you get the value as a function parameter:
onTapButton: function (event, customEventData, active) {
// Your code here to handle customEventData...
}
I hope this helps as well.
Best regards,
Zsolt
Thanks @PZsolt27 … i will try it as well …
i am still new to the environment and would like to know the best ways to accomplish my tasks …
Thanks