-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
767af84
commit a096f11
Showing
6 changed files
with
104 additions
and
13 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
indigo/sandbox/src/main/scala/com/example/sandbox/scenes/NineSliceScene.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.example.sandbox.scenes | ||
|
||
import com.example.sandbox.SandboxAssets | ||
import com.example.sandbox.SandboxGameModel | ||
import com.example.sandbox.SandboxStartupData | ||
import com.example.sandbox.SandboxViewModel | ||
import indigo._ | ||
import indigo.scenes._ | ||
import indigoextras.effectmaterials.Refraction | ||
|
||
object NineSliceScene extends Scene[SandboxStartupData, SandboxGameModel, SandboxViewModel] { | ||
|
||
type SceneModel = SandboxGameModel | ||
type SceneViewModel = SandboxViewModel | ||
|
||
def eventFilters: EventFilters = | ||
EventFilters.Restricted | ||
|
||
def modelLens: Lens[SandboxGameModel, SandboxGameModel] = | ||
Lens.keepOriginal | ||
|
||
def viewModelLens: Lens[SandboxViewModel, SandboxViewModel] = | ||
Lens.keepOriginal | ||
|
||
def name: SceneName = | ||
SceneName("nine slice scene") | ||
|
||
def subSystems: Set[SubSystem[SandboxGameModel]] = | ||
Set() | ||
|
||
def updateModel( | ||
context: SceneContext[SandboxStartupData], | ||
model: SandboxGameModel | ||
): GlobalEvent => Outcome[SandboxGameModel] = | ||
_ => Outcome(model) | ||
|
||
def updateViewModel( | ||
context: SceneContext[SandboxStartupData], | ||
model: SandboxGameModel, | ||
viewModel: SandboxViewModel | ||
): GlobalEvent => Outcome[SandboxViewModel] = | ||
_ => Outcome(viewModel) | ||
|
||
def fit(originalSize: Vector2, screenSize: Vector2): Vector2 = | ||
Vector2(Math.max(screenSize.x / originalSize.x, screenSize.y / originalSize.y)) | ||
|
||
def boxSize(t: Seconds): Int = Signal.SmoothPulse.map(d => (d * 64) + 32).map(_.toInt).at(t) | ||
|
||
def present( | ||
context: SceneContext[SandboxStartupData], | ||
model: SandboxGameModel, | ||
viewModel: SandboxViewModel | ||
): Outcome[SceneUpdateFragment] = { | ||
val viewCenter: Point = context.startUpData.viewportCenter | ||
|
||
val boxSizeValue: Int = boxSize(context.frame.time.running) | ||
|
||
Outcome( | ||
SceneUpdateFragment.empty | ||
.addLayers( | ||
Layer( | ||
Graphic( | ||
boxSizeValue, | ||
boxSizeValue, | ||
Material.Bitmap(SandboxAssets.nineSlice).nineSlice(Rectangle(16, 16, 32, 32)) | ||
).moveTo(5, 5), | ||
// Shape | ||
// .Box(Rectangle(boxSizeValue, boxSizeValue), Fill.None, Stroke(1, RGBA.Green)) | ||
// .moveTo(5, 5), | ||
Graphic( | ||
boxSizeValue, | ||
boxSizeValue, | ||
Material.Bitmap(SandboxAssets.platform).nineSlice(Rectangle(8, 20, 112, 40)) | ||
).moveTo(100, 5), | ||
// Shape | ||
// .Box(Rectangle(boxSizeValue, boxSizeValue), Fill.None, Stroke(1, RGBA.Green)) | ||
// .moveTo(75, 5), | ||
Graphic( | ||
boxSizeValue, | ||
boxSizeValue, | ||
Material.Bitmap(SandboxAssets.window).nineSlice(Rectangle(3, 15, 121, 41)) | ||
).moveTo(5, 100) | ||
// Shape | ||
// .Box(Rectangle(boxSizeValue, boxSizeValue), Fill.None, Stroke(1, RGBA.Green)) | ||
// .moveTo(5, 75), | ||
) | ||
) | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters