enchantMoonã§ä¸æ¸ãã·ã¼ã«ãä½ã£ã¦ã¿ã
ã©ãã«ã¡ã¢ãåã£ããçµµãæããå¾ã«ãã®ä¸ããæ¸ æ¸ãããã£ãã®ã§ãæ¸ããçµµãä¸æ¸ãã«ã§ããã·ã¼ã«ãä½ã£ã¦ã¿ãã
éçã§æ¸ãããã¼ã«ãã³ã§æ¸ æ¸ãæå¾ã«æ¶ãã´ã æãã®ãããªæããåç¾ã§ãã¾ãã
- çµµãæããå¾ã«ãã®ã·ã¼ã«ãã¿ãããã
- ç·ã®è²ãå¤ããã®ã§ãã®ä¸ã«æ¸ æ¸ãã
- æ¸ æ¸ãçµãã£ããã¨ãã®ã·ã¼ã«ãã¯ããã¨ãä¸æ¸ãã®çµµãæ¶ãã
ãã£ã¦ãäºã¯ç°¡åã§ãã·ã¼ã«ãã¿ãããããæã«ç·ã®è²ã®å¤æ´ã¨ã¹ããã¼ã¯ã®æçµã¤ã³ããã¯ã¹ã®ä¿åãè¡ããã·ã¼ã«ãã¯ããããæã«ä¿åããä½ç½®ããåã®ã¹ããã¼ã¯ãåé¤ãã¦ã¾ãã
 ã½ã¼ã¹ã¯ä¸è¨ã
importJS(["lib/MOON.js"
    , "lib/enchant.js"
    , "lib/ui.enchant.js"
    , "lib/color.enchant.js"
    , "lib/stylus.enchant.js"
    , "lib/puppet.enchant.js"
    , "lib/moon.puppet.enchant.js"], function() {
Â
  var LAST_INDEX_KEY="lastIndex";
  var DRAFT_COLOR=-5002905;
Â
  enchant();
  enchant.puppet.prepareTheatre({
    assets: []
  });
  StickerPuppet.create("ã·ã¼ã«", {
    behavior: [{
      stickertap: function(event) {
        var page = MOON.getCurrentPage();
        var backing = page.backing;
        var paper = MOON.getPaperJSON(backing);
        var strokes = paper.strokes;
        var lastIndex = strokes.length;
Â
        stickerStorage.setItem(LAST_INDEX_KEY, lastIndex);
        for(var i=0; i<lastIndex; i++){
          strokes[i].color = DRAFT_COLOR;
        }
        paper.strokes = strokes;
        MOON.setPaperJSON(backing,paper);
        enchant.puppet.stopTheatre();
      },
      stickerattach: function(event) {
        enchant.puppet.stopTheatre();
      },
      stickerdetach: function(event) {
        var page = MOON.getCurrentPage();
        var backing = page.backing;
        var paper = MOON.getPaperJSON(backing);
        var strokes = paper.strokes;
        var index = stickerStorage.getItem(LAST_INDEX_KEY);
Â
        strokes.splice(0, index);
        paper.strokes = strokes;
        MOON.setPaperJSON(backing,paper);
Â
        enchant.puppet.stopTheatre();
      }
    }]
  });
});
Â
æ¬å½ã¯ã·ã¼ã«ãè²¼ã£ãæã«è²å¤æ´ã¨ã¤ã³ããã¯ã¹ä¿åãè¡ãããã£ãã®ã ãã©ãstickerattachã«å¦çãè¨è¿°ããã¨ãªãããã¾ãåããªãã£ãããã
ããã«ãã¦ã enchantMoon楽ããã
Â