cocos2d-x注意事项(十)Lua发展飞机战争-4-创建主角

二战中被称为二战飞机飞机,当然,以飞机作业。这是一个游戏,我们必须加入一个飞机——这是我们的英雄。

首先创建一个层(PlaneLayer)要显示飞机。然后,create飞机初始化方法

module("PlaneLayer",package.seeall) 
local plane = nil
isAlive = true
function create()
	local planeLayer =  CCLayer:create()
	CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile("Images/shoot.plist")
	plane = CCSprite:createWithSpriteFrameName("hero1.png")
	plane:setPosition(ccp(visibleSize.width / 2,plane:getContentSize().height / 2))
	planeLayer:addChild(plane)
		
	isAlive = true
	return planeLayer
end

主角这样登场显得有些草率和唐突,如今为主角的出场加入一点效果

	local blink = CCBlink:create(1,3)
	local animation = CCAnimation:create()
	animation:setDelayPerUnit(0.1)
	animation:addSpriteFrame(CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName("hero1.png"))
	animation:addSpriteFrame(CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName("hero2.png"))
	local animate = CCAnimate:create(animation)
	
	plane:runAction(blink)
	plane:runAction(CCRepeatForever:create(animate))


 

版权声明:本文博主原创文章,博客,未经同意不得转载。

posted @ 2015-09-09 13:18  zfyouxi  阅读(164)  评论(0)    收藏  举报