Hello,
I try to program a game with brython and the js graphic library pixi.js and I need help in translating how to handle events.
I have this code written in javascript :
in the constructor of one JS object I wrote this. Image is a sprite into a canva :
function CaseJeu(x,y) {
this.x=x;
this.y=y;
...
let image = new PIXI.Sprite(textureAssiette);
image.anchor.x = 0;
image.anchor.y = 0;
image.interactive=false;
image.hitArea=zoneCliquable;
image.on('click',this.click.bind(this));
...
and after that I define a function for the event
CaseJeu.prototype.click = function(event){
....
}
I translated all in Brython and all is ok, but not the event and I don't know how to write it, I tried a few things but wihtout results
for example I whrote that
image.on('click',self.click.bind);
whith the function :
def click(self) :
print("click")
and when I click I obtain the folowing error
TypeError: Function.prototype.bind called on incompatible null
Trace de la pile :
$B.pyobj2jsobj/<@
https://cdn.rawgit.com/brython-dev/brython/3.2.6/www/src/brython.js:6617:8[10]</n.prototype.emit@file:///home/damien/Dropbox/projets_info/towerdefense/brython/javascript/pixi.min.js:2:1514
[117]</i.prototype.dispatchEvent@file:///home/damien/Dropbox/projets_info/towerdefense/brython/javascript/pixi.min.js:9:13638
[117]</i.prototype.processMouseUp@file:///home/damien/Dropbox/projets_info/towerdefense/brython/javascript/pixi.min.js:9:15461
[117]</i.prototype.processInteractive@file:///home/damien/Dropbox/projets_info/towerdefense/brython/javascript/pixi.min.js:9:14397
[117]</i.prototype.processInteractive@file:///home/damien/Dropbox/projets_info/towerdefense/brython/javascript/pixi.min.js:9:14129
[117]</i.prototype.onMouseUp@file:///home/damien/Dropbox/projets_info/towerdefense/brython/javascript/pixi.min.js:9:15150
Could someone help me ?