Scratch effect sudo code help urgent

Hi,

Can any one please help me in converting below sudo code into cocos2d js code.

****Sudo Code*
init
{
if) {
CGSize size = winSize];
;
reset = YES;
bg = ;
bg.position = ccp;
;
//Set up the burn sprite that will “knock out” parts of the darkness layer depending on the
//alpha value of the pixels in the image.
burnSprite = ;
;
;
// Scratch Background
scratchBg = retain];
scratchBg.position = ccp;
// Scratch Layer
scratchLayer = ;
scratchLayer.position = ccp;
;
;
}
return self;
}
//Move the burn sprite unless user double taps
then we reset the darkness layer

  • ccTouchesBegan:touches withEvent:event
    {
    UITouch **touch = ;
    if {
    reset = YES;
    } else {
    CGPoint location = ];
    burnSprite.position = CGPointMake;
    }
    }
    //Move the burn sprite
  • ccTouchesMoved:touches withEvent:event
    {
    UITouch**touch = ;
    CGPoint location = ];
    burnSprite.position = CGPointMake;
    }
  • tick: dt {
    if {
    ;
    ;
    // Redraw scratch background
    ;
    ;
    reset = NO;
    }
    // Update the render texture
    ;
    // Limit drawing to the alpha channel
    glColorMask;
    // Draw
    ;
    // Reset color mask
    glColorMask;
    ;
    }
    ****End of Sudo Code*

I have done Maximum of conversion just last part am unable to do which is important. Please help me * -(void) tick: (ccTime) dt {* method into cocos2d js methods.

My Converted code*****
var ScratchImage = cc.Layer.extend {
this._super;
var size = cc.Director.sharedDirector.getWinSize;
// add a “close” icon to exit the progress. it’s an autorelease object
var closeItem = cc.MenuItemImage.create {
history.go;
});
closeItem.setAnchorPoint);
var menu = cc.Menu.create;
menu.setPosition );
this.addChild;
closeItem.setPosition);
//Code Starts here
var bgImage = cc.Sprite.create;
bgImage.setPosition);
this.addChild;
var burnSprite = cc.Sprite.create;
var blendFunc = new cc.BlendFunc;
burnSprite.setBlendFunc;
this.addChild;

// Scratch Background
var scratchBg = cc.Sprite.create;
scratchBg.setPosition);
// Scratch Layer
var scratchLayer = cc.RenderTexture.create;
scratchLayer.setPosition);
this.addChild;
//[self schedule: @selector];
return true;
},
ccTouchesBegan:function {
if {
reset = true;
} else {
var location = touch.locationInView);
burnSprite.setPosition);
}
},
ccTouchMoved:function {
var location = touch.locationInView);
burnSprite.setPosition);
}
});

****End of My Converted code**

Thanks in advance.

Aparajita

How about the result?

If you got it, please share to us. Thank you.

No I didn’t get the result. Working on some thing else. Surely share with u all.