html触摸事件案例,Kinetic.js HTML5移动触摸事件开发实例

HTML

导入代码模板:

function writeMessage(message) {

text.setText(message);

layer.draw();

}

var stage = new Kinetic.Stage({

container: 'container',

width: 578,

height: 200

});

var layer = new Kinetic.Layer();

var text = new Kinetic.Text({

x: 10,

y: 10,

fontFamily: 'Calibri',

fontSize: 24,

text: '',

fill: 'black'

});

var triangle = new Kinetic.RegularPolygon({

x: 190,

y: 120,

sides: 3,

radius: 80,

fill: '#00D2FF',

stroke: 'black',

strokeWidth: 4

});

triangle.on('touchmove', function() {

var touchPos = stage.getPointerPosition();

var x = touchPos.x - 190;

var y = touchPos.y - 40;

writeMessage('x: ' + x + ', y: ' + y);

});

var circle = new Kinetic.Circle({

x: 380,

y: stage.height() / 2,

radius: 70,

fill: 'red',

stroke: 'black',

strokeWidth: 4

});

circle.on('touchstart', function() {

writeMessage('Touchstart circle');

});

circle.on('touchend', function() {

writeMessage('Touchend circle');

});

layer.add(triangle);

layer.add(circle);

layer.add(text);

stage.add(layer);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值