LocalScheduler =require(CC. Package_name.". Scheduler")LocalMainscene = Class ("Mainscene",function() returnDisplay.newscene ("Mainscene")End)functionMainscene:ctor ()--Add PlistDisplay.addspriteframes ("bandit.plist","Bandit.png") Display.addspriteframes ("gun/guns.plist","Gun/guns.png") Display.addspriteframes ("fx/fx.plist","Fx/fx.png") Display.addspriteframes ("projectiles/projectiles.plist","Projectiles/projectiles.png") Display.addspriteframes ("pickups/pickups.plist","Pickups/pickups.png") LocalHero=display.newsprite ("#player_idle1. png", display.cx,display.cy): AddTo (self)Localheroposx,heroposy=hero:getposition () hero. Collionrect={x=- the, y=- -, width= -, height= -} Localherobox={x=heroposx+Hero. Collionrect.x, y=heroposy+Hero. Collionrect.y, Width=Hero. Collionrect.width, Height=Hero. Collionrect.height} display.newsprite ("Res/test/mark.png", herobox.x,herobox.y): AddTo (self) display.newsprite ("Res/test/mark.png", herobox.x,herobox.y+herobox.height): AddTo (self) display.newsprite ("Res/test/mark.png", herobox.x+herobox.width,herobox.y): AddTo (self) display.newsprite ("Res/test/mark.png", herobox.x+herobox.width,herobox.y+herobox.height): AddTo (self)LocalCoin=display.newsprite ("#silver_coin1. png", display.cx- at, display.cy+ -): AddTo (self)Localcoinposx,coinposy=coin:getposition () coin. Collionrect={x=-8, y=- A, width= -, height= the} Localcoinbox={x=coinposx+coin. Collionrect.x, y=coinposy+coin. Collionrect.y, Width=coin. Collionrect.width, Height=coin. Collionrect.height} display.newsprite ("Res/test/mark.png", coinbox.x,coinbox.y): AddTo (self) display.newsprite ("Res/test/mark.png", coinbox.x,coinbox.y+coinbox.height): AddTo (self) display.newsprite ("Res/test/mark.png", coinbox.x+coinbox.width,coinbox.y): AddTo (self) display.newsprite ("Res/test/mark.png", coinbox.x+coinbox.width,coinbox.y+coinbox.height): AddTo (self)Print(Cc.rectintersectsrect (herobox,coinbox))EndreturnMainscene
Quick Cocos Collion