Game Development Reference
In-Depth Information
eventDispatcher:addEventListenerWithSceneGraphPriority
(listener, bg)
end
2. Once again, we register the events with the node's instance of the event dispatch-
er. The actual touches are handled by our GridController object. We'll go
over those later; first, let's build the UI. Time to work on the init method:
function GameScene:init ()
self.gridController = GridController:create()
self.gridAnimations = GridAnimations:create()
self.objectPools = ObjectPools.create()
self.gridAnimations:setGameLayer(self)
self.gridController:setGameLayer(self)
self.objectPools:createPools(self)
Create our special objects, one to handle user interactivity, another for anima-
tions, and our good old object pool.
3. Next, we add a couple of nodes and our score labels:
self:addChild( self.gemsContainer )
self.gemsContainer:setPosition( 25, 80)
--build interface
local frame = cc.Sprite:create("frame.png")
frame:setPosition(self.middle.x, self.middle.y)
self:addChild(frame)
local diamondScoreBg =
cc.Sprite:create("diamondScore.png")
diamondScoreBg:setPosition(100,
constants.SCREEN_HEIGHT - 30)
self:addChild(diamondScoreBg)
local scoreBg = cc.Sprite:create("gemsScore.png")
scoreBg:setPosition(280, constants.SCREEN_HEIGHT - 30)
self:addChild(scoreBg)
local ttfConfig = {}
ttfConfig.fontFilePath="fonts/myriad-pro.ttf"
ttfConfig.fontSize=20
self.diamondScoreLabel =
Search WWH ::




Custom Search