Project1

标题: 怎样用视频作为游戏标题? [打印本页]

作者: 老王的忧郁    时间: 2016-3-30 22:25
标题: 怎样用视频作为游戏标题?
本帖最后由 老王的忧郁 于 2016-3-31 16:46 编辑

我找到一个非常有江湖味的影片,想在标题页面播放!



求教要怎么达成?
要达成下面的效果,截图是游戏播放视频的画面

想要在标题上播放视频,游戏开始选项等要显示在视频的上层。

特别感谢@siakochen ,他介绍的插件完美的解决了我的问题!

如下图,是标题播放的视频截图!!!


现放上插件,以供同好使用!如果使用了YEP_CoreEngine这个插件,请把Scale Title 设置为false。否则会出现bitmap undefined

JAVASCRIPT 代码复制下载
  1. /*:
  2.  PH - Video Title
  3.  @plugindesc This plugin allows you to put a video at the background of the Title Screen instead of a static image.
  4.  @author PrimeHover
  5.  @version 1.1
  6.  @date 11/12/2015
  7.  ---------------------------------------------------------------------------------------
  8.  This work is licensed under the Creative Commons Attribution 4.0 International License.
  9.  To view a copy of this license, visit [url]http://creativecommons.org/licenses/by/4.0/[/url]
  10.  ---------------------------------------------------------------------------------------
  11.  @param Video Name
  12.  @desc Name of the video (See Help Section) | (E.g. "myVideo")
  13.  @param Video Muted
  14.  @desc Mutes the video in the title (0: No, 1: Yes)
  15.  @default 0
  16.  @param Video Loop
  17.  @desc Makes the video plays in a loop (0: No, 1: Yes)
  18.  @default 1
  19.  @param Video Poster Name
  20.  @desc Name and extension of the image to be shown when the video is loading (E.g. "poster.png")
  21.  @param Video Width
  22.  @desc Width of the video in the canvas (Default: 816)
  23.  @default 816
  24.  @param Video Height
  25.  @desc Height of the video in the canvas (Default: 624)
  26.  @default 624
  27.  @param Video Coord X
  28.  @desc Coordinate X of the video in the canvas (Default: 0)
  29.  @default 0
  30.  @param Video Coord Y
  31.  @desc Coordinate Y of the video in the canvas (Default: 0)
  32.  @default 0
  33.  @help
  34.  The video you want to play in background must be inside the "movies" folder in your project.
  35.  Supported extensions: "webm"
  36.  The poster you want to show while the video is not ready must be inside the "pictures" folder in your project.
  37.  */
  38.  
  39. (function() {
  40.  
  41.     /* Getting the parameters */
  42.     var parameters = PluginManager.parameters('PH_VideoTitle');
  43.     var videoName = String(parameters['Video Name']);
  44.     var posterName = String(parameters['Video Poster Name']);
  45.     var videoMuted = Number(parameters['Video Muted']);
  46.     var videoLoop = Number(parameters['Video Loop']);
  47.     var videoWidth = Number(parameters['Video Width']);
  48.     var videoHeight = Number(parameters['Video Height']);
  49.     var videoX = Number(parameters['Video Coord X']);
  50.     var videoY = Number(parameters['Video Coord Y']);
  51.  
  52.     /* Video Title Class */
  53.     var PH_VideoTitle = null;
  54.  
  55.     function VideoTitle() {
  56.         this.name = videoName;
  57.         this.posterName = posterName;
  58.  
  59.         /* Creating video tag */
  60.         this._video = document.createElement('video');
  61.         this._video.id = 'VideoTitle_' + this.name.replace(/[^A-Z0-9]+/ig, "_");
  62.         this._video.src = 'movies/' + this.name + '.webm';
  63.         this._video.style.width = 0;
  64.         this._video.style.height = 0;
  65.         this._video.autoPlay = false;
  66.  
  67.         /* Control Options */
  68.         this.setControlOptions();
  69.  
  70.         /* Appending the video at the body tag */
  71.         document.body.appendChild(this._video);
  72.  
  73.         /* Starts video and creates the texture */
  74.         this.setVideoTexture();
  75.     }
  76.     VideoTitle.prototype.constructor = VideoTitle;
  77.  
  78.     VideoTitle.prototype.setControlOptions = function() {
  79.         if (videoLoop == 1) {
  80.             this._video.loop = true;
  81.         } else {
  82.             this._video.loop = false;
  83.         }
  84.  
  85.         if (videoMuted == 1) {
  86.             this._video.muted = true;
  87.         } else {
  88.             this._video.muted = false;
  89.         }
  90.  
  91.         if (posterName.trim() != '') {
  92.             this._video.poster = 'img/pictures/' + this.posterName;
  93.         }
  94.     };
  95.  
  96.     VideoTitle.prototype.setVideoTexture = function() {
  97.         this._texture = PIXI.VideoTexture.textureFromVideo(this._video);
  98.         this._spriteVideo = new PIXI.Sprite(this._texture);
  99.         this._spriteVideo.width = videoWidth;
  100.         this._spriteVideo.height = videoHeight;
  101.         this._spriteVideo.x = videoX;
  102.         this._spriteVideo.y = videoY;
  103.     };
  104.  
  105.     VideoTitle.prototype.pauseVideo = function() {
  106.         this._video.pause();
  107.     };
  108.  
  109.     VideoTitle.prototype.playVideo = function() {
  110.         this._video.play();
  111.     };
  112.  
  113.  
  114.     /* Overwritten Scene_Title methods */
  115.     Scene_Title.prototype.create = function() {
  116.  
  117.         /* Prevent the video to be duplicated */
  118.         if (PH_VideoTitle === null) {
  119.             PH_VideoTitle = new VideoTitle();
  120.         }
  121.         this.videoTitle = PH_VideoTitle;
  122.         this.videoTitle.playVideo();
  123.         this.addChild(this.videoTitle._spriteVideo);
  124.         this.createForeground();
  125.         this.createWindowLayer();
  126.         this.createCommandWindow();
  127.     };
  128.  
  129.     Scene_Title.prototype.start = function() {
  130.         Scene_Base.prototype.start.call(this);
  131.         SceneManager.clearStack();
  132.         if (videoMuted == 1) {
  133.             this.playTitleMusic();
  134.         }
  135.         this.startFadeIn(this.fadeSpeed(), false);
  136.     };
  137.  
  138.     Scene_Title.prototype.terminate = function() {
  139.         Scene_Base.prototype.terminate.call(this);
  140.         this.videoTitle.pauseVideo();
  141.         SceneManager.snapForBackground();
  142.     };
  143.  
  144. })();

作者: siakochen    时间: 2016-3-30 23:26
歡迎參考一下我的遊戲
https://rpg.blue/thread-390613-1-1.html
我的遊戲標題選項背景就是影片

作者: 老王的忧郁    时间: 2016-3-31 00:57
siakochen 发表于 2016-3-30 23:26
歡迎參考一下我的遊戲
https://rpg.blue/thread-390613-1-1.html
我的遊戲標題選項背景就是影片

大神,你的游戏哦下载了,感觉很棒,请问你是怎么做到的?
要用你写的插件吗?
作者: siakochen    时间: 2016-3-31 11:36
老王的忧郁 发表于 2016-3-31 00:57
大神,你的游戏哦下载了,感觉很棒,请问你是怎么做到的?
要用你写的插件吗? ...

非自己寫的,此插件為作者為PrimeHover
提供你下載位置 :
http://forums.rpgmakerweb.com/in ... 338-ph-video-title/

我自己是有再編修更改成符合自己遊戲的方式

你可以去下載來試試..




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1