local scheduler = require(cc.PACKAGE_NAME .. ".scheduler") local MainScene = class("MainScene", function() return display.newScene("MainScene") end) function MainScene:ctor() --add Plist display.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") self.bullets_={} local BulletSprite=require("src/app/scenes/BulletSprite.lua") local bullet1=BulletSprite.new(1):addTo(self) bullet1:setPosition(display.cx-200,display.cy) local bullet2=BulletSprite.new(2):addTo(self) bullet2:setPosition(display.cx,display.cy) local bullet3=BulletSprite.new(3):addTo(self) bullet3:setPosition(display.cx+200,display.cy) self.bullets_[bullet1]=bullet1 self.bullets_[bullet2]=bullet2 self.bullets_[bullet3]=bullet3 self.bulletToDel_={} for key, sprite in pairs(self.bullets_) do self.bullets_[sprite]=nil end for key, sprite in pairs(self.bullets_) do sprite:removeSelf() print("***") end end return MainScene
时间: 2024-10-26 12:04:10