# Include "T05Touch. h" BoolT05Touch: init () { Layer: init (); { // Optional» ° ã Ê Ó Õ â öööö· £ £****» Ö önode ********************************************* EventListenerTouchOneByOne * ev = EventListenerTouchOneByOne: create (); Ev-> onTouchBegan = [] (Touch *, Event *) {returntrue ;}; // Ev-> onTouchEnded = [] (Touch *, Event *){}; Ev-> onTouchEnded = CC_CALLBACK_2 (T05Touch: TouchEnded, this ); _ EventDispatcher-> addEventListenerWithSceneGraphPriority (ev, this ); } # If 0 { // ********************************** EventListenerTouchOneByOne * ev = EventListenerTouchOneByOne: create (); Ev-> setSwallowTouches (true ); Ev-> onTouchBegan = [] (Touch *, Event *) {CCLog ("Touch Begin"); returntrue ;}; _ EventDispatcher-> addEventListenerWithFixedPriority (ev,-128 ); } # Endif { Sprite * node = Sprite: create (); AddChild (node ); EventListenerTouchOneByOne * ev = EventListenerTouchOneByOne: create (); Ev-> onTouchBegan = [] (Touch * touch, Event *){ // You can call touch-> getLocation () µä½ Ê ½» 'n'? ±» n? Vec2pt = touch-> getLocation (); CCLog ("Sprite is touched, pt. x = % f, pt. y = % f", pt. x, pt. y ); Returntrue; }; // Ev-> onTouchEnded = [] (Touch *, Event *){}; // Ev-> onTouchEnded = CC_CALLBACK_2 (T05Touch: TouchEnded, this ); _ EventDispatcher-> addEventListenerWithSceneGraphPriority (ev, node ); } { EventListenerTouchAllAtOnce * ev = EventListenerTouchAllAtOnce: create (); Ev-> onTouchesBegan = [] (conststd: vector &, Event *){}; _ EventDispatcher-> addEventListenerWithSceneGraphPriority (ev, this ); } Returntrue; } VoidT05Touch: TouchEnded (Touch *, Event *){ } |