Hi, i have layout with background image, and brush as sprite image. And i need eraser, but i dont have idea how make it. thx
UPD:
Here is simple example (coffeescript), I dont know whether this is the best solution. i expected something like: globalCompositeOperation=“destination-out” in native canvas, or blendFunction like in this answer How can I implement an eraser?, but i dont know how use it in cocos2d js, cant found in documetation.
BackgroundLayer = cc.Layer.extend(
ctor: ->
@_super()
@init()
init: ->
@_super()
windowSize = cc.director.getWinSize()
centerPoint = cc.p(windowSize.width / 2, windowSize.height / 2)
spriteBG = cc.Sprite.create(res.tableBg)
spriteBG.setPosition(centerPoint)
@addChild(spriteBG)
cc.eventManager.addListener
event: cc.EventListener.TOUCH_ONE_BY_ONE
onTouchMoved: (e) =>
pos = e.getLocation()
@drawImage(pos)
, @
drawImage: (pos) ->
part = cc.Sprite.create res.part
part.setPosition(pos)
part.setScale(1.5)
@addChild(part)
)