I’m getting so frustrated with Cocos… I’m getting different behaviour when running in Preview and when running in Chrome browser… if someone could please share their experience on this issue.
I have integrated web3 into Cocos following this tutorial: Building Your First Game dApp On TomoChain (Part 2) | by TomoChain Publisher | TomoChain | Medium
Now I create another custom label and changing its text to the address as follows:
//Init current account address
initAccount() {
this.Web3.eth.getAccounts().then(accounts => {
if (accounts.length > 0) {
Web3Controller.instance.CurrentAccount = accounts[0].toLowerCase();
**Web3Controller.instance.labelll.string = Web3Controller.instance.CurrentAccount;**
} else
cc.error(
"Error not connected!"
);
});
},
This works fine when running in cocos preview using browser but when I build and host the game it does not update the label with the address. It gives me error:
index.a156f.js:82 Uncaught (in promise) TypeError: Cannot set properties of null (setting 'string')
Why would it work in cocos preview but not when I build the game. This seems like a serious bug to me.