四角形をクリックするたびにテキスト値をインクリメントしようとしています。私は何を間違っていますか?私のvarへの呼び出しはdrawTextでは機能しますが、setLayerでは機能しないため、わかりません。「+ =」構文を使用している「setLayer」ソースコードを見ましたが、テキストは文字列変数であり、文字列連結を行いたくありません。
value=1
$('canvas').drawText({
name: 'count',
fillStyle: '#0f0',
x: 20, y: 20,
fontSize: 22,
fontFamily: 'Verdana, sans-serif',
text: value
})
.drawRect({
strokeStyle: '#000',
fillStyle: '#ccc',
x: 20, y: 50,
width: 20,
height: 20,
layer: true,
click: function(layer) {
// Spin
$(this).animateLayer(layer, {
rotate: '+=180'
});
v=parseInt(value);
$(this).setLayer('count',{
text: value+1 // TRYING to increment over here
});
}})