在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
--[[ Packaging_KernelEngine.h 文件说明:所有对象在建立时位置是优先的,传入位置参数必须cc.p(X,Y) CurObj:表示要传入当前的对象 将3.10 lua api 放到 C:\Users\Administrator\Documents\BabeLua\Completion ***************]] -- Valid Line Number 2901 -- local Obj = require("cocos.Packaging_Kernel") local PackagingClass = class("PackagingClass"); -- 精灵 PackagingClass.m_Sprites = { }; PackagingClass.m_SpritesPosition = { }; PackagingClass.m_SpritesWidthAndHeight = { }; -- 纹理 PackagingClass.m_Texture2D = { }; -- 粒子 PackagingClass.m_ParticleEffects = { }; -- 遮罩 PackagingClass.m_MaskTier = { }; -- 骨骼动画 PackagingClass.m_SkeletonAnimation = { }; -- 颜色层 PackagingClass.m_LayerColor = { }; -- UIButton PackagingClass.m_Button = { }; PackagingClass.m_ButtonPosition = { }; PackagingClass.m_ButtonWidthAndHeight = { }; -- Music PackagingClass.m_Music = { }; -- Font PackagingClass.m_Font = { }; -- 回调函数无参动作 PackagingClass.m_CallBackFunctionAction = { }; -- 延时动作 PackagingClass.m_DelayAction = { }; -- 连接动作 PackagingClass.m_ConnectAction = { }; -- 创建多个同时执行动作 PackagingClass.m_Spawn = { }; -- 创建一个让多个同时执行的连接动作重复动作 次数 PackagingClass.m_Repeat = { }; -- 无限动作 PackagingClass.m_InfiniteAction = { }; -- 创建一个动作移动到另一个地方再返回 PackagingClass.m_MoveToLineage = { }; -- 创建一个动作移动到另一个地方是否返回 PackagingClass.m_MoveToInfernal = { }; -- 创建一个闪烁动作 PackagingClass.m_BlinkAction = { }; -- 创建一个几秒钟内消失的动作 PackagingClass.m_SecondVanish = { }; -- 创建一个几秒钟内出现的动作 PackagingClass.m_SecondAppear = { }; -- 创建一个跳的动作(To) PackagingClass.m_JumpTo = { }; -- 创建一个跳的动作(By) PackagingClass.m_JumpBy = { }; -- 创建一个旋转动作(To) PackagingClass.m_RotateTo = { }; -- 创建一个旋转动作(By) PackagingClass.m_RotateBy = { }; -- 创建一个贝塞尔曲线动作(To)(By用的是相对坐标) PackagingClass.m_BezierAction = { }; -- =====================================3D动作 -- 创建一个3D旋转动作 PackagingClass.m_OrbitCamera = { }; -- 创建一个3D翻页动作 PackagingClass.m_PageTurn3D = { }; -- 创建一个3D扭曲动作 PackagingClass.m_Twirl = { }; -- =========================================功能性 -- 创建一个ScrollView 容器 PackagingClass.m_Scrollview = { }; PackagingClass.m_Position = { }; -- 构造函数 function PackagingClass:ctor() print("=======================packaing Call") end -- ======================================================精灵 -- 创建精灵 function PackagingClass:CreateSprite(FilePathName) self.m_Sprites = cc.Sprite:create(FilePathName); self.m_Sprites:setPosition(cc.p(0, 0)); return self.m_Sprites; end -- 设置精灵坐标 function PackagingClass:SetSpritePosition(Position) self.m_Sprites:setPosition(Position); end -- 返回精灵当前的坐标 function PackagingClass:GetSpritePosition() self.m_SpritesPosition.X, self.m_SpritesPosition.Y = self.m_Sprites:getPosition(); return self.m_SpritesPosition; end -- 返回精灵当前的宽高 function PackagingClass:GetSpriteWidthAndHeight() self.m_SpritesWidthAndHeight.Width = self.m_Sprites:getContentSize().width; self.m_SpritesWidthAndHeight.Height = self.m_Sprites:getContentSize().height; return self.m_SpritesWidthAndHeight; end -- 创建一张纹理 function PackagingClass:CreateTexture2D(FilePathName) local Texture = cc.TextureCache:getInstance():addImage(FilePathName); self.m_Texture2D = Texture; return Texture; end -- 用纹理创建一个精灵 function PackagingClass:CreateTextureSprite(Texture) local Sprite = cc.Sprite:createWithTexture(Texture); self.m_Sprites = Sprite; return Sprite; end -- 设置精灵的比例 -- 比例按百分比,在设置中源比例是1.0,及100%100源图片,填入=》精灵,cc.p(X的比例,Y的比例) -- 值得注意的是设置节点的比例,相对于XY轴也会改变,最好就设置精灵的比例就可以了 function PackagingClass:SetSpriteScale(Sprites, Scale) Sprites:setScaleX(Scale.x); Sprites:setScaleY(Scale.y); end -- 创建一个颜色层 function PackagingClass:CreateLayerColor() local LayerColor = cc.LayerColor:create(cc.c3b(0, 0, 0)) LayerColor:setOpacity(200) LayerColor:setName("UnityBackgroundColorLayer") self.m_LayerColor = LayerColor; return LayerColor; end -- ======================================================粒子 --[[//CCParticleExplosion //爆炸粒子特效 -- // CCParticleFire //火焰粒子特效 -- // CCParticleFlower //花束粒子特效 -- // CCParticleFireworks //烟花粒子特效 -- // CCParticleGalaxy //星系粒子特效 -- // CCParticleMeteor //流星粒子特效 -- // CCParticleRain //下雨粒子特效 -- // CCParticleSmoke //烟雾粒子特效 -- // CCParticleSnow //下雪粒子特效 -- // CCParticleSpiral //漩涡粒子特效 --// CCParticleSun //太阳粒子特效]] -- 烟花粒子=》文件路径,粒子数量,角度 function PackagingClass:Create_Base_ParticleEffects_Fireworks(FilePathName, Position, ParticleNumber, StartSize, EndSize, StartColor, EndColor, Speed, LifeCycle) self.m_ParticleEffects = cc.ParticleFireworks:createWithTotalParticles(ParticleNumber); self.m_ParticleEffects:retain(); self.m_ParticleEffects:setAngleVar(180); self.m_ParticleEffects:setGravity(cc.p(0, 0)); -- self.m_ParticleEffects:setSpeedVar(20); self.m_ParticleEffects:setSpeed(Speed); -- 生存周期-1为永久 self.m_ParticleEffects:setDuration(LifeCycle); self.m_ParticleEffects:setStartSize(StartSize); self.m_ParticleEffects:setEndSize(EndSize); self.m_ParticleEffects:setStartColor(StartColor); self.m_ParticleEffects:setEndColor(EndColor); self.m_ParticleEffects:setTexture(cc.TextureCache:sharedTextureCache():addImage(FilePathName)); self.m_ParticleEffects:setPosition(Position); return self.m_ParticleEffects; end -- 烟花粒子=》文件路径,粒子数量,开始颜色,结束颜色,速度,生存周期,重力, function PackagingClass:Create_Base_ParticleEffects_Fireworks2(FilePathName, Position, ParticleNumber, StartSize, EndSize, StartColor, EndColor, Speed, LifeCycle, Gravity_CCP) self.m_ParticleEffects = cc.ParticleFireworks:createWithTotalParticles(ParticleNumber); self.m_ParticleEffects:retain(); self.m_ParticleEffects:setAngleVar(180); self.m_ParticleEffects:setGravity(Gravity_CCP); -- self.m_ParticleEffects:setSpeedVar(20); self.m_ParticleEffects:setSpeed(Speed); -- 生存周期-1为永久 self.m_ParticleEffects:setDuration(LifeCycle); self.m_ParticleEffects:setStartSize(StartSize); self.m_ParticleEffects:setEndSize(EndSize); self.m_ParticleEffects:setStartColor(StartColor); self.m_ParticleEffects:setEndColor(EndColor); self.m_ParticleEffects:setTexture(cc.TextureCache:sharedTextureCache():addImage(FilePathName)); self.m_ParticleEffects:setPosition(Position); return self.m_ParticleEffects; end -- 点击效果烟花粒子=》文件路径,位置,粒子数量 function PackagingClass:Create_Ok_ParticleEffects_Fireworks(ImageName, Position, ParticleNumber) self.m_ParticleEffects = self:Create_Base_ParticleEffects_Fireworks(ImageName, Position, ParticleNumber, 20.0, 1.0, cc.c4b(0, 0, 255, 255), cc.c4b(255, 0, 255, 255), 50, 0.5); return self.m_ParticleEffects; end -- 爆炸粒子特效===>文件路径名,位置,粒子数量,角度,重力,速度,开始的大小,结束的大小,粒子生存时间,开始的颜色,结束的颜色 -- 参数参考===》Obj:Create_ParticleExplosion_Effects("ParticleSystem\\guangdian.png",cc.p(appdf.WIDTH / 2 + 9.86, appdf.HEIGHT / 2 + 20.35),100,180,cc.p(0,-100),90,20.0,10.0, 1.0,cc.c4b(255, 255, 0, 255),cc.c4b(255, 255, 255, 255)) function PackagingClass:Create_ParticleExplosion_Effects(FilePathName, Position, Number, Angle, Gravity_CCP, Speed, StartSize, EndSize, Time, StartColor, EndColor) self.m_ParticleEffects = cc.ParticleExplosion:createWithTotalParticles(Number); self.m_ParticleEffects:retain(); self.m_ParticleEffects:setAngleVar(Angle); self.m_ParticleEffects:setGravity(Gravity_CCP); self.m_ParticleEffects:setSpeed(Speed); -- 生存周期-1为永久 self.m_ParticleEffects:setDuration(Time); self.m_ParticleEffects:setStartSize(StartSize); self.m_ParticleEffects:setEndSize(EndSize); self.m_ParticleEffects:setStartColor(StartColor); self.m_ParticleEffects:setEndColor(EndColor); self.m_ParticleEffects:setTexture(cc.TextureCache:sharedTextureCache():addImage(FilePathName)); self.m_ParticleEffects:setPosition(Position); return self.m_ParticleEffects; end -- 加载plist粒子文件 function PackagingClass:LoadPlistPariticle(FilePathName) return cc.ParticleSystemQuad:create(FilePathName); end -- ======================================================遮罩 -- 在模板中设置坐标有问题时,可把模板精灵的坐标先设置,遮罩层的坐标就不用设置了 -- 创建遮罩层=》模板路径,特效路径,模板坐标,特效坐标 function PackagingClass:CreateMaskTier(Template_FilePathName, EffectsFilepathName, Template_Position, Effects_Position) local Template = cc.Sprite:create(Template_FilePathName); local Effects = cc.Sprite:create(EffectsFilepathName); Template:setPosition(Template_Position); Effects:setPosition(Effects_Position); local MaskTier = cc.ClippingNode:create(); MaskTier:setAlphaThreshold(0.5); MaskTier:setInverted(false); MaskTier:addChild(Effects); MaskTier:setStencil(Template); self.m_MaskTier = MaskTier; return MaskTier; end -- 创建遮罩层=》模板路径,特效精灵,模板坐标,特效坐标 function PackagingClass:CreateMaskTier2(Template_FilePathName, EffectsSprite, Template_Position, Effects_Position) local Template = cc.Sprite:create(Template_FilePathName); Template:setPosition(Template_Position); EffectsSprite:setPosition(Effects_Position); local MaskTier = cc.ClippingNode:create(); MaskTier:setAlphaThreshold(0.5); MaskTier:setInverted(false); MaskTier:addChild(EffectsSprite); MaskTier:setStencil(Template); self.m_MaskTier = MaskTier; return MaskTier; end -- 创建遮罩层=》模板精灵,特效精灵,模板坐标,特效坐标=====》支持 function PackagingClass:CreateMaskTier3(Template_Sprite, EffectsSprite, Template_Position, Effects_Position) Template_Sprite:setPosition(Template_Position); EffectsSprite:setPosition(Effects_Position); local MaskTier = cc.ClippingNode:create(); MaskTier:setAlphaThreshold(0.5); MaskTier:setInverted(false); MaskTier:addChild(EffectsSprite); MaskTier:setStencil(Template_Sprite); self.m_MaskTier = MaskTier; return MaskTier; end -- 创建遮罩层=》模板精灵,特效路径,模板坐标,特效坐标=====>返回模板节点,和模板精灵(进度条专用) -- 特效精灵路径=>可以用进度条中的内容,用于显示真的内容 function PackagingClass:CreateMaskTier4(Template_Sprite, EffectsFilepathSprite, Template_Position, Effects_Position) local EffectsSprite = Obj:CreateSprite(EffectsFilepathSprite); Template_Sprite:setPosition(Template_Position); EffectsSprite:setPosition(Effects_Position); local MaskTier = cc.ClippingNode:create(); MaskTier:setAlphaThreshold(0.5); MaskTier:setInverted(false); MaskTier:addChild(EffectsSprite); MaskTier:setStencil(Template_Sprite); self.m_MaskTier = MaskTier; return MaskTier; end -- ======================================================骨骼动画加载 -- 创建骨骼动画=>.json+.stlas一个文件夹下,位置,速度json动画索引 -- Ctrl + H 把json中的skinnedmesh替换为mesh function PackagingClass:CreateSkeletonAnimation(FilePathName_Json, FilePathName_Atlas, Position, TimeSpeed, BOOL, JsonIndex) -- 在json中,如果失败改一个类型 local SkeletonAnimation = sp.SkeletonAnimation:create(FilePathName_Json, FilePathName_Atlas); SkeletonAnimation:setPosition(Position); SkeletonAnimation:setTimeScale(TimeSpeed); -- json中的默认动画 SkeletonAnimation:setAnimation(0, JsonIndex, BOOL); self.m_SkeletonAnimation = SkeletonAnimation; return SkeletonAnimation; end -- 创建骨骼"OR"动画=>.csb+.png一个文件夹下,当前对象,大小比例,速度 function PackagingClass:CreateSkeletonAnimation2(FilePathName, Position, CurObj, SizeScale, TimeSpeed, BOOL) if (CurObj == nil) then return false; end local this = CurObj; local CsbNode = cc.CSLoader:createNode(FilePathName); CsbNode:setPosition(Position) CsbNode:setScale(SizeScale) local Start_Action = cc.CSLoader:createTimeline(FilePathName); Start_Action:setTimeSpeed(TimeSpeed); CsbNode:runAction(Start_Action); Start_Action:gotoFrameAndPlay(0, BOOL); this:addChild(CsbNode); return CsbNode; end -- 创建骨骼"OR"动画=>.csb+.png一个文件夹下,当前对象,大小比例,速度 function PackagingClass:CreateSkeletonAnimation3(FilePathName, Position, SizeScale, TimeSpeed, BOOL) local CsbNode = cc.CSLoader:createNode(FilePathName); CsbNode:setPosition(Position) CsbNode:setScale(SizeScale) local Start_Action = cc.CSLoader:createTimeline(FilePathName); Start_Action:setTimeSpeed(TimeSpeed); CsbNode:runAction(Start_Action); Start_Action:gotoFrameAndPlay(0, BOOL); -- 直接返回节点 return CsbNode; end -- 获取节点的子对象,也可能是子节点 -- 不能获取节点中的宽高,坐标也不可能是绝对坐标,而绝对坐标是加载csb所设置的坐标,所有子节点的坐标都是基于加载csb所设置的坐标 function PackagingClass:GetChildObj(NodeRootObj, ObjName) -- 如果返回的是节点二不是对象,则继续getChildByName("") local NodeObj = NodeRootObj:getChildByName(ObjName); if (NodeObj == nil) then -- 当前节点下没有此对象 return false; else return NodeObj, true; end -- 相反则是removeChildByName(""); end -- ======================================================帧动画动画加载 --[[文件加载路径:卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍 加载csb时,是把res文件下作为主搜索路径,在加载csb文件时,csb项目文件是和res主搜索路径相对的 --如果csb在项目中在一个文件夹下,那res中就必须有这个文件夹,否则断言 --如果csb在项目中没在一个文件夹下,那必须放这res中,如果放在其他文件夹下了,则加载时写下全路径, --如果隔了两个父文件及以上,需要添加搜索路径,否则失败 --最好把发布的资源直接扔在res下,以发布出来的文件为主 --在加载csb中的子对象时,不用再self:addChild()==>因为在加载csb整个文件是已经做了 --卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍卍]] -- 帧动画 .plist+.png一个文件夹下,位置,当前对象,总共图片,plist中图片key -- local Animation = Obj:CreateFrameAnimation("AnimationTest/EffectPlist.plist", cc.p(display.center), self, 总共多少张, "Effect/0/%d.png") function PackagingClass:CreateFrameAnimation(FilePathName, Position, CurObj, EndFrame, XmlImageName) if (CurObj == nil) then return false; end local cache = cc.SpriteFrameCache:getInstance(); cache:addSpriteFrames(FilePathName); local Test = cc.Sprite:create(); -- WithSpriteFrameName("image/boss_spider-angry_0.png") Test:setPosition(Position); local animation = cc.Animation:create(); for i = 0, EndFrame do local bing = cache:getSpriteFrame(string.format(XmlImageName, i)); animation:addSpriteFrame(bing); end -- 设置单位延迟 animation:setDelayPerUnit(0.1); animation:setRestoreOriginalFrame(true); local action = cc.Animate:create(animation); Test:runAction(cc.RepeatForever:create(action)); CurObj:addChild(Test); end -- 帧动画 .plist+.png一个文件夹下,.png,位置,当前对象,开始图片_0,结束图片_N,总共图片.plist中图片key function PackagingClass:CreateFrameAnimation2(FilePathName, Position, CurObj, StartFrame, EndFrame, XmlImageName) if (CurObj == nil) then return false; end local pshowFrame = cc.Sprite:createWithSpriteFrameName(FilePathName); pshowFrame:setPosition(Position); local animation = cc.Animation:create(); for i = StartFrame, EndFrame do local szName = string.format(XmlImageName, i); local pSpriteFrame = cc.SpriteFrameCache:getInstance():getSpriteFrame(szName); animation:addSpriteFrame(pSpriteFrame); end animation:setDelayPerUnit(0.1); animation:setRestoreOriginalFrame(true); local action = cc.Animate:create(animation); pshowFrame:runAction(cc.RepeatForever:create(action)); -- CurObj:addChild(pshowFrame); return pshowFrame; end -- ======================================================UI按钮 --按钮解决方案 -- addTouchEventListener( function(sender, tType)end)--触摸回调 --[[ ccui.TouchEventType = { began = 0, moved = 1, ended = 2, canceled = 3, } ]] -- sender:getTouchMovePosition() --获取触摸移动位置 -- touch:getTouchBeganPosition() --获取触摸开始位置 -- ... -- 创建一个普通按钮=>抬起,按下,禁用,位置,当前对象,回调函数 function PackagingClass:CreateUIButton(UpFileImageName, DownFileImageName, ProhibitFileImageName, Position, CurObj, CallBack) if (CurObj == nil) then return false; end local Button = ccui.Button:create(); Button:loadTextureNormal(UpFileImageName); Button:loadTexturePressed(DownFileImageName); Button:loadTextureDisabled(ProhibitFileImageName); Button:setPressedActionEnabled(false); -- Button:setOpacity(100);--透明度,0为完全透明 Button:setPosition(Position); if (CallBack == nil) then -- 没有传回调函数默认加一个 Button:addClickEventListener( function() end); else Button:addClickEventListener(CallBack); end self.m_Button = Button; CurObj:addChild(Button); return Button; end -- 创建一个可调比例按钮=>抬起,按下,禁用,位置,设置UI大小,当前对象,回调函数 function PackagingClass:CreateUIButton2(UpFileImageName, DownFileImageName, ProhibitFileImageName, Position, ContenSize, CurObj, CallBack) if (CurObj == nil) then return false; end local Button = ccui.Button:create(); Button:loadTextureNormal(UpFileImageName); Button:loadTexturePressed(DownFileImageName); Button:loadTextureDisabled(ProhibitFileImageName); Button:setPressedActionEnabled(false); Button:setScale9Enabled(true); ------- -- Button:setOpacity(100);--透明度,0为完全透明 if (ContenSize.x) and(ContenSize.y) then Button:setContentSize(ContenSize.x, ContenSize.y); else Button:setContentSize(ContenSize.width, ContenSize.height); end ------ Button:setPosition(Position); if (CallBack == nil) then -- 没有传回调函数默认加一个 Button:addClickEventListener( function() end); else Button:addClickEventListener(CallBack); end self.m_Button = Button; CurObj:addChild(Button); return Button; end -- 返回当前UI的位置 function PackagingClass:GetCurUIPosition() self.m_ButtonPosition.X = self.m_Button:getPositionX(); self.m_ButtonPosition.Y = self.m_Button:getPositionY(); return self.m_ButtonPosition; end -- 返回当前UI的宽高 function PackagingClass:GetUIWidthAndHeight() self.m_ButtonWidthAndHeight.Width = self.m_Button:getContentSize().width; self.m_ButtonWidthAndHeight.Height = self.m_Button:getContentSize().height; return self.m_ButtonWidthAndHeight; end -- ======================================================动作 -- 一个动作只能给一个对象用,当第二个对象用是这个动作可以当层已经是个NULL了 -- To By 区别,By多一个成员函数reverse, 这个支持方向动作reverse(颠倒) ,及(cc.p(200,200)) ==>(cc.p(-200,-200)) -- To 不支持一直无限执行 -- 创建回调函数(无参)=》动作 function PackagingClass:CreateCallBackFunction(Function) local CallBackFunction = cc.CallFunc:create(Function); self.m_CallBackFunctionAction = CallBackFunction; return CallBackFunction; end -- 创建延时动作 function PackagingClass:CreateDelayAction(Time) local DelayActionTime = cc.DelayTime:create(Time); self.m_DelayAction = DelayActionTime; return DelayActionTime; end -- 创建连接动作(一个一个执行) function PackagingClass:CreateConnectAction(...) local Sequence = cc.Sequence:create(...); self.m_ConnectAction = Sequence; return Sequence; end -- 创建多个动作同时执行的连接动作 -- 同时执行的动作只能由固定次数的动作执行 function PackagingClass:CreateMultiMeanwhileAction(...) local Spawn = cc.Spawn:create(...); self.m_Spawn = Spawn; return Spawn; end -- 创建一个让多个同时执行的连接动作重复动作 次数 function PackagingClass:CreateMultiMeanwhileAction(Action, ActionNumber) local Repeat = cc.Repeat:create(Action, ActionNumber); self.m_Repeat = Repeat; return Repeat; end -- 创建无限动作 function PackagingClass:CreateInfiniteAction(Action) local InfiniteAction = cc.RepeatForever:create(Action); self.m_InfiniteAction = InfiniteAction; return InfiniteAction; end -- 创建动作移动到另一个地方并返回 function PackagingClass:CreateMoveToLineageAction(Position_Start, Position_End, StarTime, EndTime) local MoveAction_Start = cc.MoveTo:create(StarTime, Position_Start); local MoveAction_End = cc.MoveTo:create(EndTime, Position_End); local MoveToLineage = self:CreateConnectAction(MoveAction_Start, MoveAction_End); self.m_MoveToLineage = MoveToLineage; return MoveToLineage; end -- 创建动作移动到另一个地方是否返回 function PackagingClass:CreateMoveToInfernalAction(Position_Start, BOOL, Position_End, StarTime, EndTime) if (BOOL == true) then local MoveAction_Start = cc.MoveTo:create(StarTime, Position_Start); local MoveAction_End = cc.MoveTo:create(EndTime, Position_End); local MoveToLineage = self:CreateConnectAction(MoveAction_Start, MoveAction_End); self.m_MoveToLineage = MoveToLineage; return MoveToLineage; else local MoveAction_Infernal = cc.MoveTo:create(StarTime, Position_Start); self.m_MoveToInfernal = MoveAction_Infernal; return MoveAction_Infernal; end end -- 创建动作移动到另一个地方 function PackagingClass:CreateMoveToWorld(Position_End, EndTime) local MoveAction_Infernal = cc.MoveTo:create(EndTime, Position_End); self.m_MoveToInfernal = MoveAction_Infernal; return MoveAction_Infernal; end -- 创建一个闪烁动作=》多少秒,多少次 执行完了恢复正常 function PackagingClass:CreateBlinkAction(Time, TimeNumber) local BlinkAction = cc.Blink:create(Time, TimeNumber); self.m_BlinkAction = BlinkAction; return BlinkAction; end -- 创建一个几秒钟内消失的动作 function PackagingClass:CreateSecondVanishAction(Time) local SecondVanish = cc.FadeOut:create(Time); self.m_SecondVanish = SecondVanish; return SecondVanish; end -- 创建一个几秒钟内出现的动作 function PackagingClass:CreateSecondAppearAction(Time) local SecondAppear = cc.FadeIn:create(Time); self.m_SecondAppear = SecondAppear; return SecondAppear; end -- 创建一个跳的动作(To) function PackagingClass:CreateJumpToAction(Time, Position, Height, Number) local JumpTo = cc.JumpTo:create(Time, Position, Height, Number); self.m_JumpTo = JumpTo; return JumpTo; end -- 创建一个跳的动作(By) function PackagingClass:CreateJumpByAction(Time, Position, Height, Number) local JumpBy = cc.JumpBy:create(Time, Position, Height, Number); self.m_JumpBy = JumpBy; return JumpBy; end -- 创建一个旋转的动作(To) function PackagingClass:CreateRotateToAction(Time, Angle) local RotateTo = cc.RotateTo:create(Time, Angle); self.m_RotateTo = RotateTo; return RotateTo; end -- 创建一个旋转的动作(By) function PackagingClass:CreateRotateByAction(Time, Angle) local RotateBy = cc.RotateBy:create(Time, Angle); self.m_RotateBy = RotateBy; return RotateBy; end -- 创建一个贝塞尔曲线动作(To)(By用的是相对坐标) function PackagingClass:CreateBezierToAction(Time, BezierConfig) local BezierAction = cc.BezierTo:create(Time, BezierConfig); self.m_BezierAction = BezierAction; return BezierAction; end -- 创建一个贝塞尔曲线动作(To)(By用的是相对坐标)==>时间,开始的点,弯曲的顶点(控制的点),结束的点 function PackagingClass:CreateBezierToAction2(Time, StartPoint, CurveVertex, EndPoint) local BezierConfig = { StartPoint, CurveVertex, EndPoint }; local BezierAction = cc.BezierTo:create(Time, BezierConfig); self.m_BezierAction = BezierAction; return BezierAction; end -- ======================================================3D动作 -- 3D动作说明:由于没有设置波动要持续多久,则返回的有些是无限的3D动作 -- 深度缓冲区只能开启一次,当前函数可以直接掉,不用开启OpenGL的深度缓冲区 -- 除了 Create3DRotateAction()函数可以混合使用外,其他用NodeGrid运行的不能 |
请发表评论