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))


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值