How to add listener to a sprite in cocos2d in android -


i working on cocos2d,and in need of adding listener sprite.my code here

public class gameoverscreen extends cclayer implements keyhandler {  public static ccscene scene(difficulty difficulty, long totalscore) {      ccscene result = ccscene.node();      ccsprite redeem = ccsprite.sprite("redeem.png");// listener sprite     cgsize s = ccdirector.shareddirector().winsize();     redeem.setscale(block.scale*main.scale);     redeem.setposition(-1, -1);      redeem.setanchorpoint(cgpoint.ccp(-0.7f, -1));      result.addchild(new gameoverscreen(newhighscore, totalscore));     result.addchild(redeem);      return result;   } 

@override public boolean cctouchesbegan(motionevent event) {  location = ccdirector.shareddirector().converttogl(cgpoint.ccp(event.getx(), event.gety()));       if(cgrect.containspoint((redeem.getboundingbox()), location)){       //action      }    return true; } 

short , simple trick resolve


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -