默认情况下,Kineticjsv4.0.5不支持图片边框,因此.showBorder()
和.hideBorder()
会导致错误说
未捕获的TypeError:对象#没有方法'showBorder'
但是当我加入Image Plugin v1.0.1 javascript文件时,我的游戏根本没有出现,而FireBug根本没有报错。
我还在github上开始了issue。
此致
答案 0 :(得分:3)
试试此代码
<!DOCTYPE HTML>
<html>
<head>
<script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.5.js"></script>
<script>
window.onload = function() {
var stage = new Kinetic.Stage({
container: "container",
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var imageObj = new Image();
imageObj.onload = function() {
var yoda = new Kinetic.Image({
x: 140,
y: stage.getHeight() / 2 - 59,
image: imageObj,
width: 106,
height: 118,
stroke:"Red",
strokeWidth:5
});
// add the shape to the layer
layer.add(yoda);
// add the layer to the stage
stage.add(layer);
yoda.on('mouseover', function() {
yoda.setStrokeWidth("Transparent");
yoda.setStroke(0);
layer.draw();
});
};
imageObj.src = "http://www.html5canvastutorials.com/demos/assets/yoda.jpg";
};
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>