zoukankan      html  css  js  c++  java
  • 关于unity3d播放flash动画,使用插件uniswf

    主要就是代码了。

    1.using UnityEngine;
    using System.Collections;
    using pumpkin.swf;
    using System.Collections.Generic;
    using pumpkin.events;
    using pumpkin.display;

    public class MovieClipX : MovieClip
    {


        public delegate void FrameCallback();
        public Dictionary<int, FrameCallback> FrameEvents = null;

            public MovieClipX(SwfURI uri) : base(uri)
            {
                
            }

            public MovieClipX(string linkage)
                : base(linkage)
            {
                
            }
       
        public bool  addFrameScript(string label, FrameCallback onFrameCallback)
        {
            if (string.IsNullOrEmpty(label))
                return false;


            
             int index = this.getFrameLabel(label);
           //  Debug.Log("index " + getCurrentFrame());
             if (index <= 0)
                 return false;


             if (FrameEvents == null)
             {
                 FrameEvents = new Dictionary<int, FrameCallback>();
             }


             if (!FrameEvents.ContainsKey(index))
             {
                 FrameEvents.Add(index, onFrameCallback);
             }
             else
             {
                 FrameEvents.Remove(index);
                 if (onFrameCallback != null)
                 {
                     FrameEvents.Add(index, onFrameCallback);
                 }  
             }

             return true;
           
        }

        public bool addFrameScript(int frame, FrameCallback onFrameCallback)
        {
           
           
           
            if (FrameEvents == null)
            {
                FrameEvents = new Dictionary<int, FrameCallback>();
            }

            if (!FrameEvents.ContainsKey(frame))
            {
                FrameEvents.Add(frame, onFrameCallback);
            }
            else
            {
                FrameEvents.Remove(frame);
                if (onFrameCallback != null)
                {
                    FrameEvents.Add(frame, onFrameCallback);
                }
            }


            return true;


        }


        public bool  setEndScript(FrameCallback onFrameCallback)
        {
            int index = this.getTotalFrames();
            if (index <= 0)
             return false;
            
            return addFrameScript(index,   onFrameCallback);


        }

        public override void updateFrame(CEvent e)
        {
           
            if (FrameEvents != null)
            {
                int index = this.getCurrentFrame();
                if (FrameEvents.ContainsKey(index))
                {
                    FrameCallback b = FrameEvents[index];
                    if (b != null)
                    {
                        b();
                    }
                }
            }
          
            base.updateFrame(e);
        }
    }

    2.using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using pumpkin.display;
    using pumpkin.text;
    using pumpkin.events;
    using pumpkin.logging;
    using pumpkin.tweener;


    public class FlashUI : MovieClipOverlayCameraBehaviour {
    public GameObject back;
    protected MovieClipX movie = null;
    public delegate void  OnStop();
    void Start () {
    stage.stageWidth = (float)Screen.width/1136f;
    stage.stageHeight = (float)Screen.height/640f;
    }
    public void OnPlayToEnd(string path,Vector2 pos,OnStop stop = null)
    {
    MovieClipX overlay = new MovieClipX(path);
    stage.addChild(overlay);
    //位置
    overlay.x = pos.x*stage.stageWidth;
    overlay.y = pos.y*stage.stageHeight;
    overlay.scaleX = stage.stageWidth;
    overlay.scaleY = stage.stageHeight;
    overlay.addFrameScript("end",delegate(){
    stage.removeChild(overlay);
    if(stop != null)stop();
    });
    overlay.gotoAndPlay(0);
    }
    public void OnPlayToFrame(string path,Vector2 pos,int endFrame,OnStop stop = null)
    {
    MovieClipX overlay = new MovieClipX(path);
    stage.addChild(overlay);
    //位置
    overlay.x = pos.x*stage.stageWidth;
    overlay.y = pos.y*stage.stageHeight;
    overlay.scaleX = stage.stageWidth;
    overlay.scaleY = stage.stageHeight;
    overlay.addFrameScript(endFrame,delegate(){
    stage.removeChild(overlay);
    if(stop != null)stop();
    });
    overlay.gotoAndPlay(0);
    }
    public MovieClipX OnPlayNoEnd(string path,Vector2 pos)
    {
    MovieClipX overlay = new MovieClipX(path);
    stage.addChild(overlay);
    //位置
    overlay.x = pos.x*stage.stageWidth;
    overlay.y = pos.y*stage.stageHeight;
    overlay.scaleX = stage.stageWidth;
    overlay.scaleY = stage.stageHeight;
    overlay.gotoAndPlay(0);
    return overlay;
    }
    public void ClearFlash()
    {
    stage.clearChild();
    }


  • 相关阅读:
    mysql 账户管理
    关于数据库设计的思考(三)
    学习 ThinkPHP 框架笔记
    学习 Ext Js 所感
    mysql 一个较特殊的问题:You can't specify target table 'wms_cabinet_form' for update in FROM clause
    关于数据库设计的思考(二)
    flash、flex 项目开发学习时的笔记
    web.config 中SessionState的配置
    公农历转换
    使用Microsoft Web Application Stress Tool对web进行压力测试
  • 原文地址:https://www.cnblogs.com/yxwkf/p/3836579.html
Copyright © 2011-2022 走看看