[Fixed] onEnter() stops the Event Listener

seems like I don’t understand onEnter() function on cc.Sprite , or it has some problems.

I have a parent sprite -extends cc.Sprite- , creates cards -they extend cc.Sprite also- , and every card has his own cc.eventManager.addListener() in his ctor()

I added onEnter() function to the parent Sprite - for testing I guess -,
I left it empty…
since then the listeners stopped working , and the runAction() as well ! , but let’s focus on the Listeners

do you have any idea why onEnter() is doing this ?

…this is what my sprite may look like

var HelloWorldSprite = cc.Sprite.extend({

	winSize: null,
	posId:0,

	ctor:function(){

		this._super();
		
		this.initWithFile(res.HelloWorld_png);
		
		cc.eventManager.addListener(HelloWorldListener.clone(), this);
	}
/*
	,onEnter:function(){
		
	}
*/
		
});

uncomment onEnter() , and the listener is gone !

I don’t use Javascript, but in C++ we have to call super in onEnter

1 Like

woow , it wooorks

so, that’s it ?
I should’ve know that :blush:

THANK YOU @Javy

We are all still learning Cocos!

1 Like