Cc system event editor bug?

Cc system event editor bug?
0

#1

Hi dear community,
I created one event but when i just put cc.systemEvent.on(‘somEventName’, this.someFunction, this) it generates an error in the editor console.
When i execute the code it works perfectly.

image

The error seems to say like cc.systemEvent is undefined.


Cocos Creator v2.0.7 released!
#2

Sorry, this looks like a bug in the editor. Your code looks correct, and if it executes than it’s purely in the editor. Which version of CC are you using?


#3

@skara really thank you for you reply
Latest stable version. Cocos creator 2.1


#4

I can’t reproduce this issue on creator 2.1 version.
Code:

    onLoad () {
        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
        cc.systemEvent.on("somEventName", this.somEvent, this);
    },

    start () {
        
    },

    somEvent (event) {
        cc.log("emit some Event");
    },

    onKeyDown (event) {
        cc.log(event.keyCode);
        cc.systemEvent.emit("somEventName");
    },

Did you used customized engine?


#5

@Big_Bear really thank you.
No, it’s really peculiar because i have done this in other parts of the project. I can give u some code but i need to get the office. About 2 hours you have the code for sure.


#6

Gives error


don’t gives error

Could be because extends from cc.Label? cc.Label extends cc.Component so shouldn’t be this


#7

I got the error,it cause by extends from cc.Label.I need some time to check it,feedback later


#8

To seeing if together we can find a way of solving it. Really thank you, @Big_Bear.


#9

@Big_Bear, @jare
As I see, If u extends any cc.component. onload() and start() fucntions are called even in the editor. Is that normal?
So, for example:
if i want to add some spriteframes to toggle the sprite when some entity is clicked. My way would be extend cc.sprite create 2 cc.SpriteFrame and then change the cc.Sprite.spriteFrame property to one of this spites frames.


#10

the bug cause by the cc.system is not init in the editor when you extends to engine component(like cc.Label,cc.Sprite).
we fixed it and it will update in version 2.0.7


#11

thank you for ur reply @Big_Bear.
I’m currently working at 2.1, this bug can still fixed in 2.1.1?


#12

next version will be 2.0.7
it will fix some bug of 2.0.x version.and the 2.1.1 will be a bit later