local GameBackbg = class("GameBackbg", function ( )
return display.newScene()
end)
function GameBackbg:ctor( down,mid,befor )
--背景
local bg = display.newSprite("#bgmap3.png")
bg:setAnchorPoint(cc.p(0,0))
--中间层
local mid = display.newSprite("#MapMiddle3.png")
mid:setAnchorPoint(cc.p(0,0))
--道路(英雄和敌人添加在这个下)
local r = display.newSprite("#MapGround3.png")
r:setAnchorPoint(cc.p(0,0))
--最前的植物
local befor = display.newSprite("#MapBefore3.png")
befor:setAnchorPoint(cc.p(0,0))
self.parallax = cc.ParallaxNode:create()
--添加的精灵 z值 速率 偏移
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")--预加载精灵帧
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