A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AlmasB/FXGL/commit/cb7050038 below:

added video cutscenes, closes #1120 · AlmasB/FXGL@cb70500 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+67

-1

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+67

-1

lines changed Original file line number Diff line number Diff line change

@@ -11,6 +11,7 @@

11 11

requires com.almasb.fxgl.core;

12 12

requires com.almasb.fxgl.scene;

13 13

requires javafx.controls;

14 +

requires javafx.media;

14 15

requires com.fasterxml.jackson.annotation;

15 16 16 17

exports com.almasb.fxgl.achievement;

Original file line number Diff line number Diff line change

@@ -17,6 +17,7 @@ import com.almasb.fxgl.cutscene.dialogue.DialogueScene

17 17

import com.almasb.fxgl.cutscene.dialogue.FunctionCallHandler

18 18

import com.almasb.fxgl.logging.Logger

19 19

import com.almasb.fxgl.scene.SceneService

20 +

import javafx.scene.media.MediaView

20 21 21 22

/**

22 23

*

@@ -31,7 +32,8 @@ class CutsceneService : EngineService() {

31 32

private var gameVars: PropertyMap? = null

32 33 33 34

private val scene by lazy { CutsceneScene(sceneService) }

34 -

val dialogueScene by lazy { DialogueScene(sceneService) }

35 +

private val dialogueScene by lazy { DialogueScene(sceneService) }

36 +

private val videoScene by lazy { VideoScene(sceneService) }

35 37 36 38

@JvmOverloads fun startCutscene(cutscene: Cutscene, onFinished: Runnable = EmptyRunnable) {

37 39

scene.assetLoader = assetLoader

@@ -50,6 +52,10 @@ class CutsceneService : EngineService() {

50 52

dialogueScene.start(dialogueGraph, context, functionHandler, onFinished)

51 53

}

52 54 55 +

@JvmOverloads fun startVideoCutscene(video: MediaView, onFinished: Runnable = EmptyRunnable) {

56 +

videoScene.start(video, onFinished)

57 +

}

58 + 53 59

override fun onGameReady(vars: PropertyMap) {

54 60

gameVars = vars

55 61

}

Original file line number Diff line number Diff line change

@@ -0,0 +1,59 @@

1 +

/*

2 +

* FXGL - JavaFX Game Library. The MIT License (MIT).

3 +

* Copyright (c) AlmasB (almaslvl@gmail.com).

4 +

* See LICENSE for details.

5 +

*/

6 + 7 +

package com.almasb.fxgl.cutscene

8 + 9 +

import com.almasb.fxgl.input.UserAction

10 +

import com.almasb.fxgl.input.view.KeyView

11 +

import com.almasb.fxgl.scene.SceneService

12 +

import com.almasb.fxgl.scene.SubScene

13 +

import javafx.scene.input.KeyCode

14 +

import javafx.scene.media.MediaView

15 +

import javafx.scene.paint.Color

16 + 17 +

/**

18 +

*

19 +

* @author Almas Baimagambetov (almaslvl@gmail.com)

20 +

*/

21 +

class VideoScene(private val sceneService: SceneService) : SubScene() {

22 + 23 +

private lateinit var video: MediaView

24 +

private lateinit var onFinished: Runnable

25 + 26 +

init {

27 +

input.addAction(object : UserAction("Skip Cutscene") {

28 +

override fun onActionBegin() {

29 +

endScene()

30 +

}

31 +

}, KeyCode.ENTER)

32 + 33 +

val keyView = KeyView(KeyCode.ENTER, Color.GREENYELLOW, 18.0)

34 +

keyView.translateX = sceneService.prefWidth - 80.0

35 +

keyView.translateY = sceneService.prefHeight - 40.0

36 + 37 +

contentRoot.children += keyView

38 +

}

39 + 40 +

private fun endScene() {

41 +

contentRoot.children.removeAt(0)

42 + 43 +

video.mediaPlayer.stop()

44 +

sceneService.popSubScene()

45 +

onFinished.run()

46 +

}

47 + 48 +

fun start(video: MediaView, onFinished: Runnable) {

49 +

this.video = video

50 +

this.onFinished = onFinished

51 + 52 +

video.mediaPlayer.play()

53 +

video.mediaPlayer.setOnEndOfMedia { endScene() }

54 + 55 +

contentRoot.children.add(0, video)

56 + 57 +

sceneService.pushSubScene(this)

58 +

}

59 +

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4