Hi Guys, recently I included draw + sprite in my project and I got this error.
I have read some threads, but I didn't find any solution.
Could you help me?
Code:
Ext.create({ xtype: 'draw',
plugins: 'spriteevents',
renderTo: document.body,
width: 200,
height: 200,
listeners: {
spritemousedown: function (item, event) {
var me = this,
sprite = item.sprite,
doc = Ext.getDoc(),
moveListener;
sprite.origPosition = {
x: sprite.cx,
y: sprite.cy,
offsetX: sprite.attr.cx - event.xy[0],
offsetY: sprite.attr.cy - event.xy[1]
};
moveListener = doc.on({
mousemove: function (e) {
var cx, cy,
wall = me.width - 50;
cx = (e.xy[0] > wall) ? wall : e.xy[0] + sprite.origPosition.offsetX;
cy = (e.xy[1] > wall) ? wall : e.xy[1] + sprite.origPosition.offsetY;
if (cx <= 50) { cx = 50; }
if (cy <= 50) { cy = 50; }
sprite.setAttributes({
cx: cx,
cy: cy
});
sprite.getSurface().renderFrame();
},
scope: me,
destroyable: true
});
doc.on({
mouseup: function () {
moveListener.destroy();
}
});
}
},
sprites: [
{
type: 'circle',
cx: 50,
cy: 50,
r: 50,
fillStyle: '#1F6D91'
},
]
});