2015-04-24 28 views
2

我正在用橡皮擦繪畫工具。easeljs創建繪畫工具updateCache('destination-out')

我不知道爲什麼當我點擊橡皮擦並開始清理。 整個舞臺會變得更輕。我設置updateCache('destination-out')後。

wrapper.addEventListener("pressup", function(event) { 
       console.log("up"); 
       dragging = false; 


       // real_wrapper.updateCache(); 

       if (erase == true) { 
        drawStroke(real_draw); 
        real_wrapper.updateCache('destination-out'); 

       } else { 
        drawStroke(real_draw); 
        real_wrapper.updateCache(); 
        tmp_draw.graphics.clear(); 
        wrapper.updateCache(); 
       } 

       ppts = []; 
      }); 

我的代碼:https://jsfiddle.net/steven_wong/mnfupy5o/6/ 對不起我的英語不好。

回答

2

您需要清除繪圖之間的圖形。現在,您的代碼每次都重新繪製所有舊筆畫,因此當您使用鉛筆時,所有舊圖形變暗,使用橡皮擦時,它們會變得更輕。

graphics.clear(); 

這裏有一個固定的版本: https://jsfiddle.net/mnfupy5o/7/