Search code examples
cocos2d-androidcocoscreator

How to use CustomEventData in Button component Cocos Creator 3.5.0 Typescript


In the Button component we have CustomEventData. In my understanding the purpose it to send extra parameter when user tap the button.

enter image description here

I have tried to use it like this:

use_powerUp(par: string){
    console.log("MapScreenManager::use_powerUp() = ", par);
}

The Button will call the function and I thought the CustomEventData will be automatically become 1 parameter that will fill the par parameter. But turns out it didn’t.

Can anyone guide me how to properly use the CustomEventData?

I am using Cocos Creator 3.5.0 with Typescript.


Solution

  • I just found the solution, it's very simple

    use_powerUp(event: Event, CustomEventData)
    {
    
    }