Local GAMEBACKBG = Class ("Gamebackbg", function ()
Return Display.newscene ()
End
function Gamebackbg:ctor (down,mid,befor)
--Background
Local BG = Display.newsprite ("#bgmap3. png")
Bg:setanchorpoint (CC.P (0,0))
--Middle Layer
Local mid = Display.newsprite ("#MapMiddle3. png")
Mid:setanchorpoint (CC.P (0,0))
--The road (Heroes and enemies added under this)
Local R = Display.newsprite ("#MapGround3. png")
R:setanchorpoint (CC.P (0,0))
--The most pre-plant
Local befor = Display.newsprite ("#MapBefore3. png")
Befor:setanchorpoint (CC.P (0,0))
Self.parallax = cc. Parallaxnode:create ()
--Added Sprite Z-value rate offset
Self.parallax:addChild (BG, 1, CC.P (0.2,0), CC.P (0,0))
Self.parallax:addChild (Mid, 2, CC.P (0.5,0), CC.P (0,320))
Self.parallax:addChild (R, 3, CC.P (0.8,0), CC.P (0,0))
Self.parallax:addChild (befor, 4, CC.P (0.8,0), CC.P (0,0))
Self:setanchorpoint (CC.P (0,0))
Self:addchild (Self.parallax)
Local move = CC. Moveby:create (10,CC.P ( -1000,0));
Self.parallax:runAction (move);
End
Return GAMEBACKBG
------------------------------------------
Require ("config")
Require ("Cocos.init")
Require ("Framework.init")
Require ("APP.SCENES.GAMEBACKBG")
Local MyApp = Class ("MyApp", Cc.mvc.AppBase)
function Myapp:ctor ()
MyApp.super.ctor (self)
End
function Myapp:run ()
Cc. Fileutils:getinstance (): Addsearchpath ("res/")
Display.addspriteframes ("Role.plist", "ROLE.PVR.CCZ")--pre-loaded Sprite frame
Display.addspriteframes ("Maproad.plist", "Maproad.png")
Display.addspriteframes ("Mapmid.plist", "Mapmid.png")
Display.addspriteframes ("Mapbefore.plist", "Mapbefore.png")
Display.addspriteframes ("Gamelayer.plist", "Gamelayer.png")
Display.addspriteframes ("Mapbg.plist", "Mapbg.png")
Self:enterscene ("GAMEBACKBG")
End
Return MYAPP
LUA Four background moves