-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add horizontal scrolling of parallax layers
- Loading branch information
Showing
6 changed files
with
47 additions
and
8 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
korge-fleks/src/commonMain/kotlin/korlibs/korge/fleks/familyHooks/CameraFamily.kt
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,21 @@ | ||
package korlibs.korge.fleks.familyHooks | ||
|
||
import com.github.quillraven.fleks.* | ||
import korlibs.korge.fleks.components.* | ||
import korlibs.korge.fleks.tags.* | ||
|
||
/** | ||
* Not needed because view port size is coming from entity config. | ||
* Kept here for reference. | ||
*/ | ||
val mainCameraFamily = World.family { all(SizeComponent, SizeIntComponent, MainCameraTag) } | ||
|
||
val onMainCameraAdded: FamilyHook = { entity -> | ||
// Set view port half which is the middle point of the view port | ||
val viewPortSize = entity[SizeIntComponent] | ||
val viewPortHalf = entity[SizeComponent] | ||
viewPortHalf.width = viewPortSize.width * 0.5f | ||
viewPortHalf.height = viewPortSize.height * 0.5f | ||
|
||
println("Set view port half: $viewPortHalf") | ||
} |
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
12 changes: 12 additions & 0 deletions
12
korge-fleks/src/commonMain/kotlin/korlibs/korge/fleks/tags/MainCameraTag.kt
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,12 @@ | ||
package korlibs.korge.fleks.tags | ||
|
||
import com.github.quillraven.fleks.* | ||
import kotlinx.serialization.* | ||
|
||
/** | ||
* The [MainCameraTag] component is used to specify which camera entity is used for rendering the game world. | ||
* Make sure to have only one camera entity in the game world with has [MainCameraTag] component attached. Otherwise, | ||
* the first camera entity found by the family search will be used for rendering. | ||
*/ | ||
@Serializable @SerialName("MainCamera") | ||
data object MainCameraTag : EntityTag() |