PDA

View Full Version : Workaround for sprite events?



Sharkanana
16 Feb 2015, 4:32 PM
I'm working with the drawing api and really liking my little pet project (A remake of the classic titan board game).

Any quick way to get events working with sprites until 5.1.1 release? I'm done with the basic drawing of the game and need to start with some actions. I'd hate to just have to shelf this until 5.1.1.

joel.watson
9 Mar 2015, 11:42 AM
I'm working with the drawing api and really liking my little pet project (A remake of the classic titan board game).

Any quick way to get events working with sprites until 5.1.1 release? I'm done with the basic drawing of the game and need to start with some actions. I'd hate to just have to shelf this until 5.1.1.

The fix for that would require a few overrides. Do you have a support account? If so, I'd recommend submitting a ticket.

Thanks!
Joel

jmgumaroy529
3 Sep 2015, 11:17 AM
Hi Joel, We have 5.1.2.52 version but it seems sprite events doesn't work yet. Am I right? Thanks, Jonathan

joel.watson
3 Sep 2015, 11:19 AM
Hi Joel, We have 5.1.2.52 version but it seems sprite events doesn't work yet. Am I right? Thanks, Jonathan

Hi--

They should be working. Can you share a Fiddle demonstrating the issue you're experiencing?

Thanks
Joel

jmgumaroy529
3 Sep 2015, 11:22 AM
The code is just simply below and the console log is not even called.
---
xtype: 'draw',
plugins: [
'spriteevents'
],
height: 200,
id: 'drawPanelId',
scrollable: false,
width: 1000,
sprites: [
{
type: 'rect',
x: 25,
y: 25,
width: 200,
height: 75,
fillStyle: '#66FF99',
shadowColor: '#000000',
shadowBlur: 5,
shadowOffsetX: 2,
shadowOffsetY: 2,
strokeColor: '#66CC99',
listeners: {
spriteclick: function (item, event) {
console.log('spriteclick....');
var sprite = item && item.sprite;
if (sprite) {
sprite.setAttributes({fillStyle: 'red'});
sprite.getSurface().renderFrame();
}
}
}
}]
-- Jonathan

joel.watson
3 Sep 2015, 11:26 AM
Hi--

The listeners need to be on the draw container where the plugin is defined:

https://fiddle.sencha.com/#fiddle/tb5

Thanks!
Joel

jmgumaroy529
3 Sep 2015, 11:43 AM
Hi,

I'm using Secha Architect and it doesn't let me put the function in the listener but only this which doesn't work.

https://fiddle.sencha.com/#fiddle/tb9

Jonathan

jmgumaroy529
4 Sep 2015, 5:47 AM
Is there a workaround for this while using Sencha Architect?

joel.watson
4 Sep 2015, 10:48 AM
Is there a workaround for this while using Sencha Architect?

You should be able to add an event binding directly to the draw container in Sencha Architect.

Thanks
Joel