$("#show").click(function(){
var stage = Kinetic.Node.create(json, 'container2');
var ball = new Image();
var cone = new Image();
var tshirt = new Image();
ball.onload = function() {
stage.get('.ball').apply('setImage', ball);
stage.get('.cone').apply('setImage', cone);
stage.get('.tshirt').apply('setImage', tshirt);
stage.draw();
};
ball.src = 'images/sport_soccer.png';
cone.src = 'images/cone.png';
tshirt.src = 'images/school_events.png';
});
显示按钮在新的 div 中加载舞台,我加载它很好,但如果我在舞台上有三张图像,它会在新舞台上加载三遍,依此类推
当我使用
ball.onload = function() {
stage.get('.ball').apply('setImage', ball);
stage.draw();
};
tshirt.onload = function() {
stage.get('.tshirt').apply('setImage', tshirt);
stage.draw();
};
cone.onload = function() {
stage.get('.cone').apply('setImage', cone);
stage.draw();
};
这里同样的问题。