如何使用Starling引擎在舞台上录制电影剪辑

时间:2018-11-15 14:13:42

标签: flash air display movieclip starling-framework

我买了一个ane录制屏幕,它使用了starling事件。它记录了八哥阶段,即四个旋转的圆圈。但我想录制我的电影剪辑。我可以看到我的电影剪辑出现在八哥动画中。但它仅记录八哥动画。如何记录包含电影剪辑和动画的Flash舞台?你能帮我么?预先感谢。

这是用于启动的.as文件。

 package
{

import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display3D.Context3D;
import flash.filesystem.File;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.system.Capabilities;
import flash.utils.flash_proxy;

import starling.core.Starling;
import starling.utils.RectangleUtil;
import starling.utils.ScaleMode;


[SWF(frameRate="30", backgroundColor="#000")]
public class GameplayRecorderTestAppStarling extends Sprite
{

    private var mStarling:Starling;

    public function GameplayRecorderTestAppStarling()
    {

        var stageWidth:int      = Constants.STAGE_WIDTH;
        var stageHeight:int     = Constants.STAGE_HEIGHT;
        var iOS:Boolean         = Capabilities.manufacturer.indexOf("iOS") != -1;

        Starling.multitouchEnabled = true;
        Starling.handleLostContext = !iOS;

        var viewPort:Rectangle = RectangleUtil.fit(
            new Rectangle(0, 0, stageWidth, stageHeight), 
            new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight), 
            ScaleMode.NONE); 
//  mStarling.display.stage = Starling.current.stage;
        mStarling = new Starling(Game, stage, viewPort); 
    //  mStarling = new Starling(Game, stage);
        mStarling.stage.stageWidth  = stageWidth;
        mStarling.stage.stageHeight = stageHeight;
        mStarling.simulateMultitouch  = false;
        mStarling.enableErrorChecking = Capabilities.isDebugger;
        mStarling.showStats = true;

        mStarling.antiAliasing = 1;

        mStarling.start();
    }

}

}

这是游戏的.as文件。

  public class Game extends Sprite
   {    
    private var quads:Vector.<Quad>;

    public function Game()
    {   
        addEventListener(Event.ADDED_TO_STAGE, onAdded);
    }

    private function onAdded ( e:Event ):void
    {
        quads = new Vector.<Quad>(5, true);

        //creating some quads with different colours
        //position the first four of them them in the four courners of the stage
        //and the last in the center of the screen
        quads[0] = new Quad(200, 200, 0xAA0000);
        quads[0].x = 0; quads[0].y=0;
        //set rotation center to be in the center of the quad
        quads[0].pivotX = 100; quads[0].pivotY = 100;
        addChild ( quads[0] );

        quads[1] = new Quad(200, 200, 0x00FF00);
        quads[1].x = stage.stageWidth; quads[1].y = 0;
        //set rotation center to be in the center of the quad
        quads[1].pivotX = 100; quads[1].pivotY = 100;
        addChild ( quads[1] );

        quads[2] = new Quad(200, 200, 0x0000FF);
        quads[2].x = stage.stageWidth; quads[2].y = stage.stageHeight;
        //set rotation center to be in the center of the quad
        quads[2].pivotX = 100; quads[2].pivotY = 100;
        addChild ( quads[2] );

        quads[3] = new Quad(200, 200, 0xAA00FF);
        quads[3].x = 0; quads[3].y = stage.stageHeight;
        //set rotation center to be in the center of the quad
        quads[3].pivotX = 100; quads[3].pivotY = 100;
        addChild ( quads[3] );

        quads[4] = new Quad(200, 200, 0xAAAAAA);
        quads[4].x = stage.stageWidth *0.5; quads[4].y = stage.stageHeight*0.5;
        //set rotation center to be in the center of the quad
        quads[4].pivotX = 100; quads[4].pivotY = 100;
        addChild ( quads[4] );


        this.addEventListener( TouchEvent.TOUCH, onTouch);
        this.addEventListener(EnterFrameEvent.ENTER_FRAME, onEnterFrame);

        initializeScreenRecorder();
    }

    // the corresponding event listener
    private function onEnterFrame(event:EnterFrameEvent):void
    {
        for ( var quadID:int = 0; quadID < 5; quadID++ ) 
        { 
            //rotate each quad with 36 degrees per second
            quads[quadID].rotation += 0.0174532925 * 36 * event.passedTime; 
        }
    }

    private function onTouch(event:TouchEvent):void
    {
        var touch:Touch = event.getTouch(this, TouchPhase.BEGAN);
        if(touch)
        {

            //start recording if we didn't do it already                
            if(!m_isRecording)
            {
                startRecording();
            }
            else
            {
                finishRecording();
            }

            m_isRecording = !m_isRecording;

            trace("StarlingEvent: onTouch");
        }
    }

    /* ***************************
    *    ScreenCast ANE calls
    * ***************************/
    private function initializeScreenRecorder() : void
    {
        m_screenRecorder = new GameplayRecorder();
        m_screenRecorder.addEventListener( GameplayRecorderEvent.VIDEO_SAVED, onVideoSaved );
        m_screenRecorder.addEventListener( GameplayRecorderEvent.ERROR, onScreenCastError );
    }

    /* *********************************************************************************
    *    This is where the magic...ahm...the drawing to the frame's BitmapData happens
    * *********************************************************************************/
    private function draw3dCallback( _bmp : BitmapData ):void
    {
        stage.drawToBitmapData( _bmp );
        //flash.stage.drawToBitmapData( _bmp );
    }

0 个答案:

没有答案