Getting the target sprite when using on('click')

Hey everyone!

I’m having an issue figuring out how to get the target of sprite when a user clicks on it.

For example, I’m doing something like this:

this.app.root.findByName('MyObject).script.sprite.on(‘click’, this.clickedObject, this);

Then the function I have would be:

MyExample.prototype.clickedObject = function(evt) {

}

I am passing “this” into the click call but I’m not sure how to receive it in the function. I know in other languages like AS3, I would do “evt.target” to get the object. Is there something similar here?

Thanks!

MyExample.prototype.clickedObject = function(evt) {
    this....
}

Hi Max,

The correct answer is often the simplest one, haha. Thanks, I’ll try that! Not sure why that didn’t occur to me. :-p Fridays…