├── project ├── build.properties ├── plugins.sbt └── Build.scala ├── demo ├── android │ ├── assets │ ├── res │ │ ├── drawable-hdpi │ │ │ └── icon.png │ │ ├── drawable-ldpi │ │ │ └── icon.png │ │ ├── drawable-mdpi │ │ │ └── icon.png │ │ └── values │ │ │ └── strings.xml │ ├── default.properties │ ├── project.properties │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── tripleplay │ │ │ └── demo │ │ │ └── TripleDemoActivity.java │ ├── AndroidManifest.xml │ ├── proguard.cfg │ └── pom.xml ├── robovm │ ├── resources │ │ ├── assets │ │ ├── iTunesArtwork │ │ └── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ ├── Icon-76.png │ │ │ ├── Icon-60@2x.png │ │ │ ├── Icon-76@2x.png │ │ │ ├── Icon-Small-40.png │ │ │ ├── Icon-Small-40@2x.png │ │ │ └── Contents.json │ │ │ └── LaunchImage.launchimage │ │ │ ├── Default@2x.png │ │ │ ├── Default-568h@2x.png │ │ │ ├── Default-667h@2x.png │ │ │ └── Contents.json │ ├── robovm.properties │ ├── robovm.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── tripleplay │ │ │ └── demo │ │ │ └── TripleDemoRoboVM.java │ └── Info.plist.xml ├── assets │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── TripleDemoAssets.gwt.xml │ │ │ └── assets │ │ │ │ ├── icon.png │ │ │ │ ├── flump │ │ │ │ └── atlas0.png │ │ │ │ └── images │ │ │ │ ├── scale9.png │ │ │ │ ├── smiley.png │ │ │ │ ├── asteroids.png │ │ │ │ ├── squares.png │ │ │ │ ├── background.png │ │ │ │ └── spritesheet.png │ │ │ └── unpacked │ │ │ └── assets │ │ │ └── images │ │ │ └── orb_burst_202x204.png │ └── pom.xml ├── html │ └── src │ │ └── main │ │ ├── webapp │ │ ├── favicon.ico │ │ ├── index.html │ │ └── WEB-INF │ │ │ ├── logging.properties │ │ │ ├── web.xml │ │ │ └── appengine-web.xml │ │ └── java │ │ └── tripleplay │ │ ├── TripleDemo.gwt.xml │ │ └── demo │ │ └── TripleDemoHtml.java ├── java │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── tripleplay │ │ │ └── demo │ │ │ └── TripleDemoJava.java │ └── pom.xml ├── core │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── tripleplay │ │ └── demo │ │ ├── flump │ │ └── FlumpDemo.java │ │ ├── particle │ │ ├── ParticleDemo.java │ │ └── FountainDemo.java │ │ ├── TripleDemo.java │ │ ├── anim │ │ └── FlickerDemo.java │ │ ├── ui │ │ └── SliderDemo.java │ │ └── game │ │ └── TestScreen.java ├── java-lwjgl2 │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── tripleplay │ │ │ └── demo │ │ │ └── TripleDemoJava.java │ └── pom.xml ├── java-swt │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── tripleplay │ │ │ └── demo │ │ │ └── TripleDemoJava.java │ └── pom.xml └── pom.xml ├── .gitignore ├── etc ├── SOURCE_HEADER ├── travis-deploy.sh └── bootstrap.xml ├── core ├── src │ ├── main │ │ └── java │ │ │ └── tripleplay │ │ │ ├── syncdb │ │ │ ├── Log.java │ │ │ ├── SetResolver.java │ │ │ └── Resolver.java │ │ │ ├── anim │ │ │ ├── Log.java │ │ │ └── Flipbook.java │ │ │ ├── game │ │ │ ├── Log.java │ │ │ └── trans │ │ │ │ ├── InterpedTransition.java │ │ │ │ ├── FadeTransition.java │ │ │ │ ├── AbstractTransition.java │ │ │ │ └── FlipTransition.java │ │ │ ├── TriplePlay.gwt.xml │ │ │ ├── flump │ │ │ ├── Symbol.java │ │ │ ├── Instance.java │ │ │ ├── LayerData.java │ │ │ ├── PlayMovie.java │ │ │ ├── Texture.java │ │ │ └── KeyframeData.java │ │ │ ├── ui │ │ │ ├── Log.java │ │ │ ├── Togglable.java │ │ │ ├── Clickable.java │ │ │ ├── Shim.java │ │ │ ├── bgs │ │ │ │ ├── BlankBackground.java │ │ │ │ └── RoundRectBackground.java │ │ │ ├── Icon.java │ │ │ ├── Group.java │ │ │ ├── util │ │ │ │ ├── ElementOp.java │ │ │ │ └── Supplier.java │ │ │ ├── Widget.java │ │ │ ├── ValueLabel.java │ │ │ ├── IconEffect.java │ │ │ ├── Button.java │ │ │ ├── ToggleButton.java │ │ │ ├── Layout.java │ │ │ ├── ModalShadow.java │ │ │ ├── AbstractTextButton.java │ │ │ └── SizableGroup.java │ │ │ ├── gesture │ │ │ ├── Log.java │ │ │ ├── GestureNode.java │ │ │ └── Tap.java │ │ │ ├── platform │ │ │ ├── Log.java │ │ │ ├── ImageOverlay.java │ │ │ ├── NativeOverlay.java │ │ │ ├── NativeTextField.java │ │ │ └── KeyboardFocusController.java │ │ │ ├── particle │ │ │ ├── effect │ │ │ │ ├── Move.java │ │ │ │ ├── Gravity.java │ │ │ │ ├── Drag.java │ │ │ │ └── Alpha.java │ │ │ ├── Initializer.java │ │ │ ├── Effector.java │ │ │ ├── init │ │ │ │ ├── Lifespan.java │ │ │ │ └── Color.java │ │ │ ├── ParticleBatch.java │ │ │ └── Generator.java │ │ │ ├── shaders │ │ │ └── ShaderUtil.java │ │ │ ├── util │ │ │ ├── Objects.java │ │ │ ├── Frames.java │ │ │ ├── DoubleTapper.java │ │ │ ├── DimensionValue.java │ │ │ ├── Ref.java │ │ │ ├── Conflater.java │ │ │ ├── BitVec.java │ │ │ ├── Base90.java │ │ │ └── Inflater.java │ │ │ ├── sound │ │ │ ├── Loop.java │ │ │ ├── Playable.java │ │ │ └── Clip.java │ │ │ └── entity │ │ │ └── IntBag.java │ └── test │ │ └── java │ │ └── tripleplay │ │ ├── util │ │ ├── BitVecTest.java │ │ ├── TypedStorageTest.java │ │ ├── BagTest.java │ │ ├── Base90Test.java │ │ └── ConflaterTest.java │ │ ├── anim │ │ └── AnimatorTest.java │ │ ├── entity │ │ └── EntityTest.java │ │ ├── syncdb │ │ └── ProtocolTest.java │ │ ├── particle │ │ └── ParticleBufferTest.java │ │ └── ui │ │ └── util │ │ └── Scale9Test.java └── pom.xml ├── .travis.yml ├── AUTHORS.md ├── java-swt ├── pom.xml └── src │ └── main │ └── java │ └── tripleplay │ └── platform │ └── SWTNativeOverlay.java ├── java-lwjgl2 ├── pom.xml └── src │ └── main │ └── java │ └── tripleplay │ └── platform │ ├── JavaImageOverlay.java │ └── JavaNativeOverlay.java ├── ios ├── pom.xml └── src │ └── main │ └── java │ └── tripleplay │ └── platform │ ├── IOSImageOverlay.java │ ├── IOSNativeOverlay.java │ └── IOSUIOverlay.java ├── LICENSE ├── plugins ├── convert-flump-libs │ └── pom.xml └── pom.xml └── tools └── pom.xml /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.1 2 | -------------------------------------------------------------------------------- /demo/android/assets: -------------------------------------------------------------------------------- 1 | ../assets/src/main/resources/assets -------------------------------------------------------------------------------- /demo/robovm/resources/assets: -------------------------------------------------------------------------------- 1 | /Users/mdb/projects/tripleplay/demo/robovm/../assets/src/main/resources/assets -------------------------------------------------------------------------------- /demo/assets/src/main/resources/TripleDemoAssets.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /demo/robovm/resources/iTunesArtwork: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/iTunesArtwork -------------------------------------------------------------------------------- /demo/html/src/main/webapp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/html/src/main/webapp/favicon.ico -------------------------------------------------------------------------------- /demo/android/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/android/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /demo/android/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/android/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /demo/android/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/android/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/icon.png -------------------------------------------------------------------------------- /demo/android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TP Demo 4 | 5 | -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/flump/atlas0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/flump/atlas0.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/images/scale9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/images/scale9.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/images/smiley.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/images/smiley.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/images/asteroids.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/images/asteroids.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/images/squares.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/images/squares.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/images/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/images/background.png -------------------------------------------------------------------------------- /demo/assets/src/main/resources/assets/images/spritesheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/resources/assets/images/spritesheet.png -------------------------------------------------------------------------------- /demo/assets/src/main/unpacked/assets/images/orb_burst_202x204.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/assets/src/main/unpacked/assets/images/orb_burst_202x204.png -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /demo/robovm/robovm.properties: -------------------------------------------------------------------------------- 1 | app.version=1.0 2 | app.id=tripleplay.demo 3 | app.mainclass=tripleplay.demo.TripleDemoRoboVM 4 | app.executable=TripleDemoRoboVM 5 | app.build=1 6 | app.name=TripleDemo 7 | -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | *.iml 4 | .settings/ 5 | target 6 | demo/android/bin 7 | demo/android/gen 8 | demo/android/obj 9 | demo/ios/bin 10 | demo/ios/obj 11 | demo/ios/demo.userprefs 12 | -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Icon-Small-40@2x.png -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/threerings/tripleplay/HEAD/demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Default-667h@2x.png -------------------------------------------------------------------------------- /etc/SOURCE_HEADER: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | -------------------------------------------------------------------------------- /demo/html/src/main/java/tripleplay/TripleDemo.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /demo/android/default.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "build.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-11 12 | -------------------------------------------------------------------------------- /demo/html/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Triple Play Demo 5 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /etc/travis-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Deploys artifacts to SonaType snapshots repository if we're building master branch. 4 | # 5 | # This ensures that we don't try to deploy to SonaType if we're building a pull request branch or 6 | # doing other miscellaneous business. 7 | 8 | if [[ $TRAVIS_BRANCH == 'master' ]]; then 9 | git clone https://github.com/samskivert/travis-maven-deploy.git target/travis 10 | mvn deploy --settings target/travis/settings.xml 11 | fi 12 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/syncdb/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.syncdb; 7 | 8 | import tripleplay.util.Logger; 9 | 10 | /** Provides logging for this package. */ 11 | class Log 12 | { 13 | /** Provides logging for this package. */ 14 | public static final Logger log = new Logger("syncdb"); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/anim/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.anim; 7 | 8 | import tripleplay.util.Logger; 9 | 10 | /** 11 | * Provides logging for this package. 12 | */ 13 | class Log 14 | { 15 | /** Provides logging for this package. */ 16 | public static final Logger log = new Logger("tpanim"); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/game/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.game; 7 | 8 | import tripleplay.util.Logger; 9 | 10 | /** 11 | * Provides logging for this package. 12 | */ 13 | class Log 14 | { 15 | /** Provides logging for this package. */ 16 | public static final Logger log = new Logger("tpgame"); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/TriplePlay.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/flump/Symbol.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.flump; 7 | 8 | /** Defines a Flump symbol. */ 9 | public interface Symbol 10 | { 11 | /** The exported name of this symbol. */ 12 | String name (); 13 | 14 | /** Creates a new instance of this symbol. */ 15 | Instance createInstance (); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import tripleplay.util.Logger; 9 | 10 | /** 11 | * Provides logging for the TriplePlay UI package. 12 | */ 13 | class Log 14 | { 15 | /** Provides logging for the TriplePlay UI package. */ 16 | public static final Logger log = new Logger("tpui"); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/gesture/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.gesture; 7 | 8 | import tripleplay.util.Logger; 9 | 10 | /** 11 | * Provides logging for the TriplePlay Gesture package. 12 | */ 13 | class Log 14 | { 15 | /** Provides logging for the TriplePlay Gesture package. */ 16 | public static final Logger log = new Logger("tpgesture"); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/platform/Log.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import tripleplay.util.Logger; 9 | 10 | /** 11 | * Provides logging for the TriplePlay Platform package. 12 | */ 13 | class Log 14 | { 15 | /** Provides logging for the TriplePlay Platform package. */ 16 | public static final Logger log = new Logger("tppf"); 17 | } 18 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | // we use pom-util to read metadata from the Maven POMs 2 | libraryDependencies += "com.samskivert" % "sbt-pom-util" % "0.6" 3 | 4 | // this wires up JRebel; start demo with JRebel via: demo-java/re-start 5 | addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.1") 6 | 7 | // we use proguard to package up our tools 8 | // resolvers += Resolver.url( 9 | // "sbt-plugin-releases-scalasbt", 10 | // url("http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns) 11 | 12 | // addSbtPlugin("org.scala-sbt" % "xsbt-proguard-plugin" % "0.1.3") 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | after_success: etc/travis-deploy.sh 3 | sudo: false 4 | 5 | jdk: 6 | - openjdk8 7 | - openjdk11 8 | 9 | cache: 10 | directories: 11 | - '$HOME/.m2/repository' 12 | 13 | env: 14 | global: 15 | - secure: "azTOm427TYgWCE/zGqQpSu1PU1w6CGF7noqKsxGkLMlj6tl4TDYVsywvywflFWnmOuhDykAIXiamBv/xh5RCef0P0ekfE4e9HKJ0+3NsTuqw/ecqeNv7ztT8H7KiM3cN+eRxl9jX4GiLBNoHIDc8v9913odbyXzRtwE/EViy8vI=" 16 | - secure: "HWZdbiwuEjCViga0sk6SflAtmRgsQihV+mO0hsgLGK43MNxJS/7xQVPpSWKoaxd1Jd5nzAu5jg/7fy3cDZgviOjG3m8A9K5XvLwWa/ltq6gKu8qG+vY/miN5myOnT0U9Xs13awptCFz0Gm30tCJ7znxdPhMmQGBix1BNdM1XGRU=" 17 | -------------------------------------------------------------------------------- /demo/html/src/main/webapp/WEB-INF/logging.properties: -------------------------------------------------------------------------------- 1 | # A default java.util.logging configuration. 2 | # (All App Engine logging is through java.util.logging by default). 3 | # 4 | # To use this configuration, copy it into your application's WEB-INF 5 | # folder and add the following to your appengine-web.xml: 6 | # 7 | # 8 | # 9 | # 10 | # 11 | 12 | # Set the default logging level for all loggers to one of: 13 | # SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST 14 | .level = ${gae.loglevel} 15 | -------------------------------------------------------------------------------- /demo/android/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-11 15 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Togglable.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import react.Value; 9 | 10 | /** 11 | * Implemented by {@link Element}s that expose a selected state and can be clicked. 12 | */ 13 | public interface Togglable> extends Clickable 14 | { 15 | /** A value that reflects the current selection state and is updated when said state changes. */ 16 | Value selected (); 17 | } 18 | -------------------------------------------------------------------------------- /demo/html/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | index.html 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Clickable.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import react.SignalView; 9 | 10 | /** 11 | * Implemented by {@link Element}s that can be clicked. 12 | */ 13 | public interface Clickable> 14 | { 15 | /** A signal that is emitted when this element is clicked. */ 16 | SignalView clicked (); 17 | 18 | /** Programmatically triggers a click of this element. */ 19 | void click (); 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/platform/ImageOverlay.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import playn.core.Image; 9 | 10 | /** 11 | * A native overlay that simply draws an playn image. 12 | */ 13 | public interface ImageOverlay extends NativeOverlay 14 | { 15 | /** 16 | * Gets the image. 17 | */ 18 | Image image (); 19 | 20 | /** 21 | * Queues up a repaint. Games must call this whenever the image is updated. 22 | */ 23 | void repaint (); 24 | } 25 | -------------------------------------------------------------------------------- /demo/android/src/main/java/tripleplay/demo/TripleDemoActivity.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo; 7 | 8 | import android.util.DisplayMetrics; 9 | 10 | import playn.android.GameActivity; 11 | 12 | public class TripleDemoActivity extends GameActivity 13 | { 14 | @Override public void main () { 15 | new TripleDemo(platform()); 16 | } 17 | 18 | protected float scaleFactor () { 19 | DisplayMetrics dm = getResources().getDisplayMetrics(); 20 | return Math.min(2, dm.density); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/effect/Move.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle.effect; 7 | 8 | import tripleplay.particle.Effector; 9 | import static tripleplay.particle.ParticleBuffer.*; 10 | 11 | /** 12 | * Moves particles based on their velocity. 13 | */ 14 | public class Move extends Effector 15 | { 16 | @Override public void apply (int index, float[] data, int start, float now, float dt) { 17 | data[start + TX] += data[start + VEL_X] * dt; 18 | data[start + TY] += data[start + VEL_Y] * dt; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/flump/Instance.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.flump; 7 | 8 | import react.Closeable; 9 | 10 | import playn.scene.Layer; 11 | 12 | /** A created instance of a Flump symbol. */ 13 | public interface Instance extends Closeable { 14 | 15 | /** The layer that displays this instance. */ 16 | Layer layer (); 17 | 18 | /** 19 | * Notifies this instance that time has passed, for animation. 20 | * @param dt The time since the last update, in milliseconds. 21 | */ 22 | void paint (float dt); 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/shaders/ShaderUtil.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.shaders; 7 | 8 | /** 9 | * Shader related utility methods. 10 | */ 11 | public class ShaderUtil 12 | { 13 | /** 14 | * Formats a floating point value for inclusion in a shader program. Ensures that the value 15 | * always contains a '.' and a trailing '0' if needed. 16 | */ 17 | public static String format (float value) { 18 | String fmt = String.valueOf(value); 19 | return fmt.indexOf('.') == -1 ? (fmt + ".0") : fmt; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Shim.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import pythagoras.f.Dimension; 9 | import pythagoras.f.IDimension; 10 | 11 | /** 12 | * An invisible widget that simply requests a fixed amount of space. 13 | */ 14 | public class Shim extends SizableWidget 15 | { 16 | public Shim (float width, float height) { 17 | this(new Dimension(width, height)); 18 | } 19 | 20 | public Shim (IDimension size) { 21 | super(size); 22 | } 23 | 24 | @Override protected Class getStyleClass () { 25 | return Shim.class; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/util/Objects.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | /** 9 | * Utilities that apply to all objects. This will mostly reflect ideas originally consolidated 10 | * in com.google.common.base, but not roping in the whole of guava. 11 | */ 12 | public class Objects 13 | { 14 | /** 15 | * Tests if two objects match according to reference equality, or {@link Object#equals(Object)} 16 | * if both are non-null. 17 | */ 18 | public static boolean equal (Object o1, Object o2) { 19 | return o1 == o2 || (o1 != null && o1.equals(o2)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/tripleplay/util/BitVecTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import org.junit.*; 9 | import static org.junit.Assert.*; 10 | 11 | public class BitVecTest 12 | { 13 | @Test public void test () { 14 | BitVec vec = new BitVec(4); 15 | for (int ii = 0; ii < 10000; ii++) assertFalse(vec.isSet(ii)); 16 | for (int ii = 0; ii < 10000; ii++) vec.set(ii); 17 | for (int ii = 0; ii < 10000; ii++) assertTrue(vec.isSet(ii)); 18 | for (int ii = 0; ii < 10000; ii++) vec.clear(ii); 19 | for (int ii = 0; ii < 10000; ii++) assertFalse(vec.isSet(ii)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demo/html/src/main/java/tripleplay/demo/TripleDemoHtml.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo; 7 | 8 | import com.google.gwt.core.client.EntryPoint; 9 | 10 | import playn.html.HtmlPlatform; 11 | 12 | public class TripleDemoHtml implements EntryPoint { 13 | 14 | @Override public void onModuleLoad () { 15 | HtmlPlatform.Config config = new HtmlPlatform.Config(); 16 | HtmlPlatform plat = new HtmlPlatform(config); 17 | plat.setTitle("TriplePlay Demo"); 18 | plat.assets().setPathPrefix("tripledemo/"); 19 | // plat.disableRightClickContextMenu(); 20 | new TripleDemo(plat); 21 | plat.start(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/bgs/BlankBackground.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui.bgs; 7 | 8 | import pythagoras.f.IDimension; 9 | 10 | import playn.scene.GroupLayer; 11 | 12 | import tripleplay.ui.Background; 13 | 14 | /** 15 | * A background that displays nothing. This is the default for groups. 16 | */ 17 | public class BlankBackground extends Background 18 | { 19 | @Override protected Instance instantiate (IDimension size) { 20 | return new Instance(size) { 21 | @Override public void addTo (GroupLayer parent, float x, float y, float depthAdjust) {} 22 | @Override public void close () {} 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/platform/NativeOverlay.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import pythagoras.f.IRectangle; 9 | 10 | /** 11 | * A platform element that draws on top of the main playn root layer. 12 | */ 13 | public interface NativeOverlay 14 | { 15 | /** 16 | * Sets the bounds of the overlay, in root coordinates. 17 | */ 18 | void setBounds (IRectangle bounds); 19 | 20 | /** 21 | * Adds the native overlay to the display. If the overlay is already added, does nothing. 22 | */ 23 | void add (); 24 | 25 | /** 26 | * Removes the native overlay from the display. If the overlay is already removed, does 27 | * nothing. 28 | */ 29 | void remove (); 30 | } 31 | -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "667h", 7 | "filename" : "Default-667h@2x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "retina4", 16 | "filename" : "Default-568h@2x.png", 17 | "minimum-system-version" : "7.0", 18 | "orientation" : "portrait", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "orientation" : "portrait", 23 | "idiom" : "iphone", 24 | "extent" : "full-screen", 25 | "minimum-system-version" : "7.0", 26 | "filename" : "Default@2x.png", 27 | "scale" : "2x" 28 | }, 29 | ], 30 | "info" : { 31 | "version" : 1, 32 | "author" : "xcode" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /demo/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/platform/NativeTextField.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | /** 9 | * Provides access to a platform-native text field, which can be overlaid onto a PlayN game. 10 | * A TP Field is required for integration. See {@link TPPlatform#createNativeTextField( 11 | * tripleplay.ui.Field.Native)}. 12 | */ 13 | public interface NativeTextField extends NativeOverlay 14 | { 15 | /** Sets the enabled state of the field. */ 16 | void setEnabled (boolean enabled); 17 | 18 | /** Request focus for the native text field */ 19 | void focus (); 20 | 21 | /** Inserts the given text at the current caret position, or if there is a selected region, 22 | * replaces the region with the given text. 23 | * @return true if the operation was successful */ 24 | boolean insert (String text); 25 | } 26 | -------------------------------------------------------------------------------- /demo/robovm/resources/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "40x40", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-Small-40@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "60x60", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-60@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "ipad", 18 | "filename" : "Icon-Small-40.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "ipad", 24 | "filename" : "Icon-Small-40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "76x76", 29 | "idiom" : "ipad", 30 | "filename" : "Icon-76.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "76x76", 35 | "idiom" : "ipad", 36 | "filename" : "Icon-76@2x.png", 37 | "scale" : "2x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Icon.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import playn.scene.Layer; 9 | import react.RFuture; 10 | 11 | /** 12 | * An interface for icons. 13 | */ 14 | public interface Icon 15 | { 16 | /** 17 | * Returns the width of this icon. If the icon is not yet loaded, this should return zero. 18 | */ 19 | float width (); 20 | 21 | /** 22 | * Returns the height of this icon. If the icon is not yet loaded, this should return zero. 23 | */ 24 | float height (); 25 | 26 | /** 27 | * Creates a new layer for displaying this icon. The caller is takes ownership of the new layer 28 | * and is responsible for its destruction. 29 | */ 30 | Layer render (); 31 | 32 | /** 33 | * A future which is completed when this icon has loaded. 34 | */ 35 | RFuture state (); 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/tripleplay/anim/AnimatorTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.anim; 7 | 8 | import org.junit.*; 9 | import static org.junit.Assert.*; 10 | 11 | public class AnimatorTest 12 | { 13 | @Test public void testAnimDoubleRegisterFreakout () { 14 | Animator anim = new Animator(); 15 | Runnable NOOP = new Runnable() { public void run () {} }; 16 | AnimBuilder chain = anim.action(NOOP).then(); 17 | // it's OK to keep chaining animations 18 | chain.action(NOOP).then().action(NOOP); 19 | // it's not OK to try to chain an animation off the then() builder to which we kept a 20 | // reference and off of which we have already chained an animation 21 | try { 22 | chain.action(NOOP); 23 | fail("Double register failed to freakout"); 24 | } catch (IllegalStateException ise) {} // success 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Triple Play Authors and Contributors 2 | 3 | Triple Play was originally developed at [Three Rings Design] by the following people: 4 | 5 | * mdb (samskivert.com) - Michael Bayne 6 | * jamie (threerings.net) - Jamie Doornbos 7 | * nathan.curtis (gmail.com) - Nathan Curtis 8 | * karma (deadmoose.com) - David Hoover 9 | * charlie.groves (gmail.com) - Charlie Groves 10 | * b (aduros.com) - Bruno Garcia 11 | * mthomas (threerings.net) - Michael Thomas 12 | * tconkling (gmail.com) - Tim Conkling 13 | * matt (threerings.net) - Matt Jensen 14 | * ebyan (threerings.net) - Ebyan Alvarez-Buylla 15 | * zell (threerings.net) - Pär Winzell 16 | 17 | Along the way, various contributions, large and small have come from members of the PlayN 18 | community: 19 | 20 | * bryanchacosky (gmail.com) - Bryan Chacosky 21 | * guille.rodriguez (gmail.com) - Guillermo Rodríguez 22 | * rsennov (corp.finam.ru) - Ruslan Sennov 23 | 24 | If anyone is missing from this glorious record, please submit a pull request with appropriate 25 | additions. 26 | 27 | [Three Rings Design]: https://en.wikipedia.org/wiki/Three_Rings_Design 28 | -------------------------------------------------------------------------------- /java-swt/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.threerings 6 | tripleplay-parent 7 | 2.1-SNAPSHOT 8 | 9 | 10 | tripleplay-java-swt 11 | jar 12 | 13 | TP Java SWT 14 | Java-specific code for TriplePlay, using PlayN SWT backend. 15 | 16 | 17 | 18 | com.threerings 19 | tripleplay 20 | ${project.version} 21 | 22 | 23 | 24 | io.playn 25 | playn-java-swt 26 | ${playn.version} 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /demo/robovm/robovm.xml: -------------------------------------------------------------------------------- 1 | 2 | ${app.executable} 3 | ${app.mainclass} 4 | ios 5 | thumbv7 6 | 7 | 8 | resources 9 | 10 | 11 | ios 12 | Info.plist.xml 13 | 14 | 15 | SQLite.JDBCDriver 16 | SQLite.JDBC2z.JDBCConnection 17 | 18 | com.android.org.conscrypt.OpenSSLProvider 19 | org.apache.harmony.security.provider.cert.DRLCertFactory 20 | com.android.org.bouncycastle.jce.provider.BouncyCastleProvider 21 | org.apache.harmony.security.provider.crypto.CryptoProvider 22 | com.android.org.conscrypt.JSSEProvider 23 | com.android.org.conscrypt.OpenSSLMessageDigestJDK$SHA1 24 | 25 | 26 | -------------------------------------------------------------------------------- /java-lwjgl2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.threerings 6 | tripleplay-parent 7 | 2.1-SNAPSHOT 8 | 9 | 10 | tripleplay-java-lwjgl2 11 | jar 12 | 13 | TP Java LWJGL 14 | Java-specific code for TriplePlay, using PlayN LWJGL2 backend. 15 | 16 | 17 | 18 | com.threerings 19 | tripleplay 20 | ${project.version} 21 | 22 | 23 | 24 | io.playn 25 | playn-java-lwjgl2 26 | ${playn.version} 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/platform/KeyboardFocusController.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import pythagoras.f.Point; 9 | 10 | /** Defines application hooks into controlling focus on native text fields. */ 11 | public interface KeyboardFocusController 12 | { 13 | /** Return true if the keyboard focus should be relinquished for a pointer that starts at the 14 | * given location. 15 | * 16 | * The default (with no KeyboardFocusController specified) is to relinquish focus for any point 17 | * that does not start on a native text field. With this method, fine control is possible, 18 | * allowing some in-game UI to be interacted with without losing focus if desired. */ 19 | boolean unfocusForLocation (Point location); 20 | 21 | /** Called each time a field has the return key pressed. Return true to relinquish the 22 | * keyboard. */ 23 | boolean unfocusForEnter (); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/flump/LayerData.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.flump; 7 | 8 | import java.util.Collections; 9 | import java.util.List; 10 | 11 | public class LayerData 12 | { 13 | /** The authored name of this layer. */ 14 | public final String name; 15 | 16 | /** The keyframes in this layer. */ 17 | public final List keyframes; 18 | 19 | public LayerData (String name, List keyframes) { 20 | this.name = name; 21 | this.keyframes = Collections.unmodifiableList(keyframes); 22 | } 23 | 24 | /** The number of frames in this layer. */ 25 | public int frames () { 26 | KeyframeData lastKf = keyframes.get(keyframes.size() - 1); 27 | return lastKf.index + lastKf.duration; 28 | } 29 | 30 | // these are filled in by Library after the library is loaded 31 | protected boolean _multipleSymbols; 32 | protected Symbol _lastSymbol; 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/game/trans/InterpedTransition.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.game.trans; 7 | 8 | import tripleplay.util.Interpolator; 9 | 10 | /** 11 | * Handles shared code for transitions that use an interpolation. 12 | */ 13 | public abstract class InterpedTransition> 14 | extends AbstractTransition 15 | { 16 | public T linear () { return interp(Interpolator.LINEAR); } 17 | public T easeIn () { return interp(Interpolator.EASE_IN); } 18 | public T easeOut () { return interp(Interpolator.EASE_OUT); } 19 | public T easeInOut () { return interp(Interpolator.EASE_INOUT); } 20 | 21 | public T interp (Interpolator interp) { 22 | _interp = interp; 23 | return asT(); 24 | } 25 | 26 | protected Interpolator defaultInterpolator () { 27 | return Interpolator.EASE_INOUT; 28 | } 29 | 30 | protected Interpolator _interp = defaultInterpolator(); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/sound/Loop.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.sound; 7 | 8 | /** 9 | * Represents a looped sound (i.e. music). 10 | */ 11 | public interface Loop extends Playable 12 | { 13 | /** A noop loop. */ 14 | class Silence implements Loop { 15 | @Override public float volume () { return 0; } 16 | @Override public void setVolume (float volume) {} 17 | @Override public boolean isPlaying () { return false; } 18 | @Override public void play () {} 19 | @Override public void fadeIn (float fadeMillis) {} 20 | @Override public void fadeOut (float fadeMillis) {} 21 | @Override public void stop () {} 22 | @Override public void release () {} 23 | } 24 | 25 | /** Fades this loop in over the specified duration. */ 26 | void fadeIn (float fadeMillis); 27 | 28 | /** Fades this loop out over the specified duration. */ 29 | void fadeOut (float fadeMillis); 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/game/trans/FadeTransition.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.game.trans; 7 | 8 | import playn.core.Platform; 9 | 10 | import tripleplay.game.ScreenStack.Screen; 11 | 12 | /** 13 | * Fades the new screen in front of the old one. 14 | */ 15 | public class FadeTransition extends InterpedTransition 16 | { 17 | @Override public void init (Platform plat, Screen oscreen, Screen nscreen) { 18 | super.init(plat, oscreen, nscreen); 19 | nscreen.layer.setAlpha(0); 20 | } 21 | 22 | @Override public boolean update (Screen oscreen, Screen nscreen, float elapsed) { 23 | float nalpha = _interp.applyClamp(0, 1, elapsed, _duration); 24 | nscreen.layer.setAlpha(nalpha); 25 | return elapsed >= _duration; 26 | } 27 | 28 | @Override public void complete (Screen oscreen, Screen nscreen) { 29 | super.complete(oscreen, nscreen); 30 | nscreen.layer.setAlpha(1); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Group.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | /** 9 | * A grouping element that contains other elements and lays them out according to a layout policy. 10 | */ 11 | public class Group extends Elements 12 | { 13 | /** 14 | * Creates a group with the specified layout and styles. 15 | */ 16 | public Group (Layout layout, Styles styles) { 17 | super(layout); 18 | setStyles(styles); 19 | } 20 | 21 | /** 22 | * Creates a group with the specified layout and styles (in the DEFAULT mode). 23 | */ 24 | public Group (Layout layout, Style.Binding... styles) { 25 | super(layout); 26 | setStyles(styles); 27 | } 28 | 29 | /** 30 | * Creates a group with the specified layout. 31 | */ 32 | public Group (Layout layout) { 33 | super(layout); 34 | } 35 | 36 | @Override protected Class getStyleClass () { 37 | return Group.class; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /demo/android/proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class com.android.vending.licensing.ILicensingService 14 | 15 | -keepclasseswithmembernames class * { 16 | native ; 17 | } 18 | 19 | -keepclasseswithmembernames class * { 20 | public (android.content.Context, android.util.AttributeSet); 21 | } 22 | 23 | -keepclasseswithmembernames class * { 24 | public (android.content.Context, android.util.AttributeSet, int); 25 | } 26 | 27 | -keepclassmembers enum * { 28 | public static **[] values(); 29 | public static ** valueOf(java.lang.String); 30 | } 31 | 32 | -keep class * implements android.os.Parcelable { 33 | public static final android.os.Parcelable$Creator *; 34 | } 35 | -------------------------------------------------------------------------------- /java-lwjgl2/src/main/java/tripleplay/platform/JavaImageOverlay.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import java.awt.Graphics; 9 | 10 | import javax.swing.JComponent; 11 | 12 | import playn.core.Image; 13 | import playn.java.JavaImage; 14 | 15 | public class JavaImageOverlay extends JavaNativeOverlay 16 | implements ImageOverlay 17 | { 18 | public JavaImageOverlay (JavaTPPlatform plat, Image image) { 19 | super(plat, new ImageComponent((JavaImage)image)); 20 | } 21 | 22 | public Image image () { 23 | return ((ImageComponent)component).image; 24 | } 25 | 26 | public void repaint () { 27 | component.repaint(); 28 | } 29 | 30 | protected static class ImageComponent extends JComponent 31 | { 32 | public final JavaImage image; 33 | 34 | public ImageComponent (JavaImage image) { 35 | this.image = image; 36 | } 37 | 38 | @Override public void paint (Graphics g) { 39 | g.drawImage(image.bufferedImage(), 0, 0, null); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ios/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.threerings 6 | tripleplay-parent 7 | 2.0-SNAPSHOT 8 | 9 | 10 | tripleplay-ios 11 | jar 12 | 13 | Triple Play iOS 14 | iOS-specific code for TriplePlay. 15 | 16 | 17 | 18 | com.threerings 19 | tripleplay 20 | ${project.version} 21 | 22 | 23 | 24 | io.playn 25 | playn-ios 26 | ${playn.version} 27 | 28 | 29 | 30 | com.xamarin 31 | monotouch 32 | ${monotouch.version} 33 | provided 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/flump/PlayMovie.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.flump; 7 | 8 | import tripleplay.anim.Animation; 9 | 10 | /** Plays a movie until it ends. */ 11 | public class PlayMovie extends Animation 12 | { 13 | public PlayMovie (Movie movie) { 14 | _movie = movie; 15 | } 16 | 17 | @Override protected void init (float time) { 18 | super.init(time); 19 | _lastTime = time; 20 | _movie.setPosition(0); 21 | } 22 | 23 | @Override protected float apply (float time) { 24 | float dt = time - _lastTime; 25 | _lastTime = time; 26 | 27 | float remaining = _movie.symbol().duration - _movie.position() - dt*_movie.speed(); 28 | if (remaining < 0) { 29 | dt = (_movie.symbol().duration-_movie.position()) / _movie.speed(); 30 | } 31 | _movie.paint(dt); 32 | return remaining; 33 | } 34 | 35 | @Override protected void makeComplete () { 36 | _movie.paint((_movie.symbol().duration-_movie.position()) / _movie.speed()); 37 | } 38 | 39 | protected Movie _movie; 40 | protected float _lastTime; 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/Initializer.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle; 7 | 8 | /** 9 | * Used to initialize a new particle. 10 | */ 11 | public abstract class Initializer 12 | { 13 | /** 14 | * Called just before an initializer is used to initialize one or more particles. Gives the 15 | * initializer a chance to do any computation that will be shared across all particles 16 | * initialized on this frame. 17 | */ 18 | public void willInit (int count) {} // nada by default 19 | 20 | /** 21 | * Applies this initializer to the {@code index}th particle in the supplied buffer. The 22 | * initializer must use the {@link ParticleBuffer} offsets to write fields into {@code data}, 23 | * for example: {@code data[start+ParticleBuffer.POS_X] = x}. 24 | * 25 | * @param index the index of the particle, which can be used to index into other per-particle 26 | * data arrays. 27 | * @param data the particle field data. 28 | * @param start the offset into {@code data} at which the particle's fields start. 29 | */ 30 | public abstract void init (int index, float[] data, int start); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/effect/Gravity.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle.effect; 7 | 8 | import tripleplay.particle.Effector; 9 | import tripleplay.particle.ParticleBuffer; 10 | 11 | /** 12 | * Applies uniform gravity to particles. 13 | */ 14 | public class Gravity extends Effector 15 | { 16 | /** Earth gravity. */ 17 | public static final float EARTH_G = 9.81f; 18 | 19 | /** Creates a gravity effector with earth equivalent gravity. */ 20 | public Gravity () { 21 | this(EARTH_G); 22 | } 23 | 24 | /** 25 | * Creates a gravity effector. 26 | * 27 | * @param accel the constant acceleration to apply to the y velocity of a particle. Positive 28 | * accelerates the particle toward the bottom of the screen. 29 | */ 30 | public Gravity (float accel) { 31 | _accel = accel; 32 | } 33 | 34 | // TODO: account for device orientation in willInit (will need vel vector) 35 | 36 | @Override public void apply (int index, float[] data, int start, float now, float dt) { 37 | data[start + ParticleBuffer.VEL_Y] += _accel * dt; 38 | } 39 | 40 | protected final float _accel; 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/util/Frames.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import pythagoras.f.IPoint; 9 | import pythagoras.f.IRectangle; 10 | 11 | import playn.scene.ImageLayer; 12 | 13 | /** 14 | * Models the frames of a flipbook animation. The image frames may be trimmed, in which case the 15 | * image for a given frame may have an offset within the logical bounds of the entire flipbook. 16 | */ 17 | public interface Frames 18 | { 19 | /** Returns the width of a logical frame. */ 20 | float width (); 21 | 22 | /** Returns the height of a logical frame. */ 23 | float height (); 24 | 25 | /** Returns the number of frames available. */ 26 | int count (); 27 | 28 | /** Returns the bounds for the specified frame. */ 29 | IRectangle bounds (int index); 30 | 31 | /** Returns the offset (into the logical bounds) of the specified frame. */ 32 | IPoint offset (int index); 33 | 34 | /** Configures the supplied image layer with the specified frame. The layer's image will be 35 | * updated and the layer's translation will be adjusted to the requested frame's offset */ 36 | void apply (int index, ImageLayer layer); 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/Effector.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle; 7 | 8 | /** 9 | * Encapsulates a single effect on a particle, for example, moving it based on its current 10 | * velocity. 11 | */ 12 | public abstract class Effector 13 | { 14 | /** 15 | * Applies this effector to the {@code index}th particle in the supplied buffer. The effector 16 | * must use the {@link ParticleBuffer} offsets to extract fields from {@code data}, for 17 | * example: {@code float x = data[start+ParticleBuffer.POS_X]}. 18 | * 19 | * @param index the index of the particle, which can be used to index into other per-particle 20 | * data arrays. 21 | * @param data the particle field data. 22 | * @param start the offset into {@code data} at which the particle's fields start. 23 | * @param now the number of seconds elapsed since the emitter came into being. Can be used to 24 | * compute a particle's age. 25 | * @param dt the amount of time (in fractions of a second) that has elapsed since the last 26 | * update. 27 | */ 28 | public abstract void apply (int index, float[] data, int start, float now, float dt); 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/util/ElementOp.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui.util; 7 | 8 | import tripleplay.ui.Element; 9 | 10 | /** 11 | * Defines a method that applies an operation to an element. 12 | * @param the leaf type of Element. 13 | */ 14 | public abstract class ElementOp> 15 | { 16 | /** 17 | * Returns an element operation that enables or disables its elements. Usage: 18 | *
{@code
19 |      *     Hierarchy.of(elem).apply(ElementOp.setEnabled(false));
20 |      * }
21 | */ 22 | public static ElementOp> setEnabled (final boolean enabled) { 23 | return new ElementOp>() { 24 | @Override public void apply (Element elem) { 25 | elem.setEnabled(enabled); 26 | } 27 | }; 28 | } 29 | 30 | /** 31 | * Applies an arbitrary operation to the given element. 32 | */ 33 | public abstract void apply (T elem); 34 | 35 | /** 36 | * Iterates the given elements and applies this operation to each. 37 | */ 38 | public final void applyToEach (Iterable elems) { 39 | for (T elem : elems) apply(elem); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/init/Lifespan.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle.init; 7 | 8 | import tripleplay.util.Randoms; 9 | 10 | import tripleplay.particle.Initializer; 11 | import tripleplay.particle.ParticleBuffer; 12 | 13 | /** 14 | * Initializers for a particle's lifespan. 15 | */ 16 | public class Lifespan 17 | { 18 | /** 19 | * Returns an initializer that provides a constant lifespan. 20 | */ 21 | public static Initializer constant (final float lifespan) { 22 | return new Initializer() { 23 | @Override public void init (int index, float[] data, int start) { 24 | data[start+ParticleBuffer.LIFESPAN] = lifespan; 25 | } 26 | }; 27 | } 28 | 29 | /** 30 | * Returns an initializer that provides a random lifespan between {@code min} and {@code max}. 31 | */ 32 | public static Initializer random (final Randoms rando, final float min, final float max) { 33 | return new Initializer() { 34 | @Override public void init (int index, float[] data, int start) { 35 | data[start+ParticleBuffer.LIFESPAN] = rando.getInRange(min, max); 36 | } 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Widget.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | /** 9 | * The base class for all user interface widgets. Provides helper methods for managing a canvas 10 | * into which a widget is rendered when its state changes. 11 | */ 12 | public abstract class Widget> extends Element 13 | { 14 | protected Widget () { 15 | _behave = createBehavior(); 16 | if (_behave != null) { 17 | // absorbs clicks and do not descend (propagate clicks to sublayers) 18 | set(Flag.HIT_DESCEND, false); 19 | set(Flag.HIT_ABSORB, true); 20 | // wire up our behavior as a layer listener 21 | layer.events().connect(_behave); 22 | } 23 | } 24 | 25 | @Override protected void layout () { 26 | super.layout(); 27 | if (_behave != null) _behave.layout(); 28 | } 29 | 30 | /** 31 | * Creates the behavior for this widget, if any. Defaults to returning null, which means no 32 | * behavior. This is called once, in the widget's constructor. 33 | */ 34 | protected Behavior createBehavior () { 35 | return null; 36 | } 37 | 38 | protected final Behavior _behave; 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/effect/Drag.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle.effect; 7 | 8 | import tripleplay.particle.Effector; 9 | import static tripleplay.particle.ParticleBuffer.*; 10 | 11 | /** 12 | * Applies friction (drag) to particles. 13 | */ 14 | public class Drag extends Effector 15 | { 16 | /** 17 | * Creates a drag effector with uniform x and y drag. 18 | * 19 | * @param drag the fraction of the velocity to preserve on each frame (0 to 1). 20 | */ 21 | public Drag (float drag) { 22 | this(drag, drag); 23 | } 24 | 25 | /** 26 | * Creates a drag effector with the specified x and y drag. 27 | * 28 | * @param dragX the fraction of the x velocity to preserve on each frame (0 to 1). 29 | * @param dragY the fraction of the y velocity to preserve on each frame (0 to 1). 30 | */ 31 | public Drag (float dragX, float dragY) { 32 | _dragX = dragX; 33 | _dragY = dragY; 34 | } 35 | 36 | @Override public void apply (int index, float[] data, int start, float now, float dt) { 37 | data[start + VEL_X] *= _dragX; 38 | data[start + VEL_Y] *= _dragY; 39 | } 40 | 41 | protected final float _dragX, _dragY; 42 | } 43 | -------------------------------------------------------------------------------- /ios/src/main/java/tripleplay/platform/IOSImageOverlay.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import playn.core.Image; 9 | import playn.ios.IOSAbstractImage; 10 | import cli.MonoTouch.CoreGraphics.CGContext; 11 | import cli.MonoTouch.UIKit.UIGraphics; 12 | import cli.MonoTouch.UIKit.UIView; 13 | import cli.System.Drawing.RectangleF; 14 | 15 | public class IOSImageOverlay extends IOSNativeOverlay 16 | implements ImageOverlay 17 | { 18 | public IOSImageOverlay (Image image) { 19 | super(new ImageView(((IOSAbstractImage)image))); 20 | } 21 | 22 | @Override public Image image () { 23 | return ((ImageView)view).image; 24 | } 25 | 26 | @Override public void repaint () { 27 | root().SetNeedsDisplay(); 28 | } 29 | 30 | protected static class ImageView extends UIView 31 | { 32 | public final IOSAbstractImage image; 33 | 34 | public ImageView (IOSAbstractImage image) { 35 | this.image = image; 36 | } 37 | 38 | @Override public void Draw (RectangleF frame) { 39 | super.Draw(frame); 40 | CGContext ctx = UIGraphics.GetCurrentContext(); 41 | ctx.DrawImage(frame, image.cgImage()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/ValueLabel.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import react.Closeable; 9 | import react.ValueView; 10 | 11 | /** 12 | * @deprecated Use {@link Label#Label(ValueView)}. 13 | */ 14 | @Deprecated 15 | public class ValueLabel extends TextWidget 16 | { 17 | /** The source for the text of this label. */ 18 | public final ValueView text; 19 | 20 | /** Creates a label with the supplied value. The value will be converted to a string for 21 | * display as this label's text. */ 22 | public ValueLabel (ValueView text) { 23 | this.text = text; 24 | } 25 | 26 | @Override protected void wasAdded () { 27 | super.wasAdded(); 28 | _conn = text.connect(textDidChange()); 29 | } 30 | 31 | @Override protected void wasRemoved () { 32 | super.wasRemoved(); 33 | _conn.close(); 34 | } 35 | 36 | @Override public String toString () { return "VLabel(" + text.get() + ")"; } 37 | @Override protected Class getStyleClass () { return Label.class; } 38 | @Override protected String text () { return String.valueOf(text.get()); } 39 | @Override protected Icon icon () { return null; } 40 | 41 | protected Closeable _conn; 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/sound/Playable.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.sound; 7 | 8 | /** 9 | * Shared controls for clips and loops. 10 | */ 11 | public interface Playable 12 | { 13 | /** Returns the current volume configured for this clip. Note that the actual volume will be 14 | * the configured volume multiplied by the master volume of the owning soundboard. */ 15 | float volume (); 16 | 17 | /** Configures the volume for this clip to a value between 0 and 1. Note that the actual volume 18 | * will be the configured volume multiplied by the master volume of the owning soundboard. */ 19 | void setVolume (float volume); 20 | 21 | /** Returns true if this playable is currently playing, false otherwise. */ 22 | boolean isPlaying (); 23 | 24 | /** Starts this clip or loop playing. If the sound data is not yet loaded it will be loaded and 25 | * then played. */ 26 | void play (); 27 | 28 | /** Stops this clip or loop (fading it out over one second). */ 29 | void stop (); 30 | 31 | /** Releases this playable when it is no longer needed. This releases any associated audio 32 | * resources.If this playable is used again, the underlying sound will be reloaded. */ 33 | void release (); 34 | } 35 | -------------------------------------------------------------------------------- /demo/java/src/main/java/tripleplay/demo/TripleDemoJava.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo; 7 | 8 | import java.util.List; 9 | 10 | import com.google.common.collect.Lists; 11 | 12 | import playn.core.Image; 13 | import playn.java.JavaPlatform; 14 | import playn.java.LWJGLPlatform; 15 | 16 | public class TripleDemoJava 17 | { 18 | public static void main (String[] args) { 19 | LWJGLPlatform.Config config = new LWJGLPlatform.Config(); 20 | config.appName = "Tripleplay Demo"; 21 | 22 | List mainArgs = Lists.newArrayList(); 23 | String size = "--size="; 24 | for (int ii = 0; ii < args.length; ii++) { 25 | if (args[ii].startsWith(size)) { 26 | String[] wh = args[ii].substring(size.length()).split("x"); 27 | config.width = Integer.parseInt(wh[0]); 28 | config.height = Integer.parseInt(wh[1]); 29 | } 30 | // else if (args[ii].equals("--retina")) config.scaleFactor = 2; 31 | else mainArgs.add(args[ii]); 32 | } 33 | 34 | TripleDemo.mainArgs = mainArgs.toArray(new String[0]); 35 | JavaPlatform plat = new LWJGLPlatform(config); 36 | new TripleDemo(plat); 37 | plat.start(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /demo/core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.threerings 6 | tripleplay-demo 7 | 2.1-SNAPSHOT 8 | 9 | 10 | tripleplay-demo-core 11 | jar 12 | TP Demo Core 13 | 14 | 15 | 16 | ${project.groupId} 17 | tripleplay 18 | ${project.version} 19 | 20 | 21 | 22 | com.google.guava 23 | guava 24 | ${guava.version} 25 | 26 | 27 | 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-source-plugin 33 | 34 | 35 | 36 | 37 | 38 | 39 | ${project.build.sourceDirectory} 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /core/src/test/java/tripleplay/entity/EntityTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.entity; 7 | 8 | import org.junit.Test; 9 | import static org.junit.Assert.assertEquals; 10 | 11 | import playn.core.Clock; 12 | 13 | import tripleplay.entity.Component; 14 | import tripleplay.entity.Entity; 15 | import tripleplay.entity.World; 16 | 17 | public class EntityTest { 18 | 19 | class TestWorld extends World { 20 | public final Component.IScalar comp = new Component.IScalar(this); 21 | public final TestSystem sys = new TestSystem(this); 22 | class TestSystem extends System { 23 | public int entitiesUpdated = 0; 24 | public TestSystem (World world) { super(world, 0); } 25 | @Override protected boolean isInterested (Entity entity) { 26 | return entity.has(comp); 27 | } 28 | @Override protected void update (Clock clock, Entities entities) { 29 | entitiesUpdated = entities.size(); 30 | } 31 | } 32 | } 33 | 34 | @Test public void testUpdate () { 35 | TestWorld world = new TestWorld(); 36 | Entity e = world.create(true).add(world.comp); 37 | world.update(null); 38 | assertEquals(1, world.sys.entitiesUpdated); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/tripleplay/syncdb/ProtocolTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.syncdb; 7 | 8 | import org.junit.*; 9 | import static org.junit.Assert.*; 10 | 11 | public class ProtocolTest 12 | { 13 | @Test public void testPayloadInts () { 14 | Protocol.PayloadWriter out = new Protocol.PayloadWriter(); 15 | for (int ii = 0; ii < 2*Short.MAX_VALUE; ii += 17) { 16 | out.writeInt(ii); 17 | } 18 | Protocol.PayloadReader in = new Protocol.PayloadReader(out.payload()); 19 | for (int ii = 0; ii < 2*Short.MAX_VALUE; ii += 17) { 20 | assertEquals(ii, in.readInt()); 21 | } 22 | } 23 | 24 | @Test public void testPayloadStrings () { 25 | Protocol.PayloadWriter out = new Protocol.PayloadWriter(); 26 | out.writeString("one"); 27 | out.writeInt(42); 28 | out.writeString("two"); 29 | out.writeString(""); 30 | out.writeString(null); 31 | Protocol.PayloadReader in = new Protocol.PayloadReader(out.payload()); 32 | assertEquals("one", in.readString()); 33 | assertEquals(42, in.readInt()); 34 | assertEquals("two", in.readString()); 35 | assertEquals("", in.readString()); 36 | assertTrue(null == in.readString()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /demo/core/src/main/java/tripleplay/demo/flump/FlumpDemo.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo.flump; 7 | 8 | import playn.core.Clock; 9 | 10 | import react.Slot; 11 | 12 | import tripleplay.flump.*; 13 | import tripleplay.ui.Group; 14 | import tripleplay.ui.Root; 15 | import tripleplay.ui.layout.AbsoluteLayout; 16 | 17 | import tripleplay.demo.DemoScreen; 18 | 19 | public class FlumpDemo extends DemoScreen 20 | { 21 | @Override protected String name () { 22 | return "Flump"; 23 | } 24 | 25 | @Override protected String title () { 26 | return "Flump animation"; 27 | } 28 | 29 | @Override protected Group createIface (Root root) { 30 | final Group main = new Group(new AbsoluteLayout()); 31 | JsonLoader.loadLibrary(game().plat, "flump").onSuccess(new Slot() { 32 | public void onEmit (Library lib) { 33 | final Movie movie = lib.createMovie("walk"); 34 | movie.layer().setTranslation(size().width()/2, 300); 35 | main.layer.add(movie.layer()); 36 | closeOnHide(paint.connect(new Slot() { 37 | public void onEmit (Clock clock) { movie.paint(clock); } 38 | })); 39 | } 40 | }); 41 | return main; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/init/Color.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle.init; 7 | 8 | import tripleplay.particle.Initializer; 9 | import tripleplay.particle.ParticleBuffer; 10 | 11 | /** 12 | * Initializes the color value of a particle. 13 | */ 14 | public class Color 15 | { 16 | /** 17 | * Returns an initializer that initializes the particle's color to the supplied constant value. 18 | */ 19 | public static Initializer constant (int argb) { 20 | return constant(((argb >> 16) & 0xFF) / 255f, 21 | ((argb >> 8) & 0xFF) / 255f, 22 | ((argb >> 0) & 0xFF) / 255f, 23 | ((argb >> 24) & 0xFF) / 255f); 24 | } 25 | 26 | /** 27 | * Returns an initializer that initializes the particle's color to the supplied constant value. 28 | */ 29 | public static Initializer constant (final float r, final float g, final float b, final float a) { 30 | return new Initializer() { 31 | @Override public void init (int index, float[] data, int start) { 32 | data[start+ParticleBuffer.ALPHA_RED] = playn.core.Color.encode(a, r); 33 | data[start+ParticleBuffer.GREEN_BLUE] = playn.core.Color.encode(g, b); 34 | } 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/util/DoubleTapper.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import playn.core.Event; 9 | 10 | /** 11 | * Detects double taps on a layer, using a threshold time between taps. Two taps that occur 12 | * within a time span shorter than the threshold are considered a double tap. 13 | */ 14 | public class DoubleTapper extends Tapper 15 | { 16 | /** Maximum time between taps for the 2nd to be considered a double. */ 17 | public final static double DOUBLE_TIME = 500; 18 | 19 | @Override public void onTap (Event.XY where) { 20 | super.onTap(where); 21 | if (where.time - _tapTime < DOUBLE_TIME) onDoubleTap(where); 22 | else _tapTime = where.time; 23 | } 24 | 25 | /** 26 | * Called when a double tap occurs. This is a simpler version of {@link 27 | * #onDoubleTap(Event.XY)}, for subclasses that don't require the event position. 28 | */ 29 | public void onDoubleTap () {} 30 | 31 | /** 32 | * Called when a double tap occurs. By default, this just calls {@link #onDoubleTap()}. 33 | * Subclasses overriding this needn't call super. 34 | * @param where the pointer's end position (for the 2nd tap) 35 | */ 36 | public void onDoubleTap (Event.XY where) { onDoubleTap(); } 37 | 38 | /** Last tap time recorded. */ 39 | protected double _tapTime; 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/sound/Clip.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.sound; 7 | 8 | import playn.core.Sound; 9 | 10 | /** 11 | * Represents a one-shot clip. 12 | */ 13 | public interface Clip extends Playable 14 | { 15 | /** A noop clip. */ 16 | class Silence implements Clip { 17 | @Override public float volume () { return 0; } 18 | @Override public void setVolume (float volume) {} 19 | @Override public boolean isPlaying () { return false; } 20 | @Override public void play () {} 21 | @Override public void fadeIn (float fadeMillis) {} 22 | @Override public void fadeOut (float fadeMillis) {} 23 | @Override public void stop () {} 24 | @Override public void release () {} 25 | @Override public void preload () {} 26 | @Override public Sound asSound () { return new Sound(); } 27 | } 28 | 29 | /** Fades this clip in over the specified duration. */ 30 | void fadeIn (float fadeMillis); 31 | 32 | /** Fades this clip out over the specified duration. */ 33 | void fadeOut (float fadeMillis); 34 | 35 | /** Preloads this clip's underlying audio data. */ 36 | void preload (); 37 | 38 | /** Views this clip as a {@link Sound}. Only the {@link Sound#play} and {@link Sound#stop} 39 | * methods can be used. Useful for passing a clip into code that expects {@link Sound}. */ 40 | Sound asSound (); 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/java/tripleplay/util/TypedStorageTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import org.junit.*; 9 | import static org.junit.Assert.*; 10 | 11 | import react.Function; 12 | import react.Functions; 13 | import react.RSet; 14 | 15 | import playn.core.Platform; 16 | import playn.core.StubPlatform; 17 | 18 | public class TypedStorageTest 19 | { 20 | @Test public void testSetFor () { 21 | Platform pf = new StubPlatform(); 22 | TypedStorage ts = new TypedStorage(pf.log(), pf.storage()); 23 | Function id = Functions.identity(); 24 | 25 | RSet strings = ts.setFor("strings", id, id); 26 | assertTrue(strings.isEmpty()); 27 | strings.add("one"); 28 | 29 | // (each call to setFor creates a new set from the curren state of storage) 30 | assertTrue(ts.setFor("strings", id, id).contains("one")); 31 | 32 | strings.remove("one"); 33 | assertTrue(ts.setFor("strings", id, id).isEmpty()); 34 | 35 | strings.add(""); 36 | assertTrue(ts.setFor("strings", id, id).contains("")); 37 | strings.add("two"); 38 | assertTrue(ts.setFor("strings", id, id).contains("")); 39 | strings.remove("two"); 40 | assertTrue(ts.setFor("strings", id, id).contains("")); 41 | strings.remove(""); 42 | assertFalse(ts.setFor("strings", id, id).contains("")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Triple Play library - utilities for use in PlayN-based games 2 | Copyright (c) 2011, Three Rings Design, Inc. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | * The name Three Rings may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /demo/html/src/main/webapp/WEB-INF/appengine-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/util/DimensionValue.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import pythagoras.f.Dimension; 9 | import pythagoras.f.IDimension; 10 | import react.Value; 11 | 12 | /** 13 | * A specialized {@code Value} for dimensions. 14 | */ 15 | public class DimensionValue extends Value 16 | { 17 | /** 18 | * Creates a new value with the given dimension. 19 | */ 20 | public DimensionValue (IDimension value) { 21 | super(value); 22 | } 23 | 24 | /** 25 | * Creates a new value with a new dimension of the given width and height. 26 | */ 27 | public DimensionValue (float width, float height) { 28 | super(new Dimension(width, height)); 29 | } 30 | 31 | /** 32 | * Updates the value to a new dimension of the given width and height. 33 | */ 34 | public void update (float width, float height) { 35 | update(new Dimension(width, height)); 36 | } 37 | 38 | /** 39 | * Updates the value to a new dimension with the current height and the given width. 40 | */ 41 | public void updateWidth (float width) { 42 | update(new Dimension(width, get().height())); 43 | } 44 | 45 | /** 46 | * Updates the value to a new dimension with the current width and the given height. 47 | */ 48 | public void updateHeight (float height) { 49 | update(new Dimension(get().width(), height)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/flump/Texture.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.flump; 7 | 8 | import pythagoras.f.IPoint; 9 | 10 | import playn.core.Tile; 11 | import playn.scene.ImageLayer; 12 | 13 | public class Texture implements Instance 14 | { 15 | public static class Symbol implements tripleplay.flump.Symbol 16 | { 17 | public Tile tile; 18 | public final IPoint origin; 19 | 20 | public Symbol (String name, IPoint origin, Tile tile) { 21 | _name = name; 22 | this.origin = origin; 23 | setSource(tile); 24 | } 25 | 26 | public void setSource (Tile tile) { 27 | this.tile = tile; 28 | } 29 | 30 | @Override public String name () { return _name; } 31 | @Override public Texture createInstance () { return new Texture(this); } 32 | 33 | protected final String _name; 34 | } 35 | 36 | protected Texture (Symbol symbol) { 37 | _layer = new ImageLayer(symbol.tile); 38 | _layer.setOrigin(symbol.origin.x(), symbol.origin.y()); 39 | _symbol = symbol; 40 | } 41 | 42 | public Symbol symbol () { return _symbol; } 43 | 44 | @Override public ImageLayer layer () { return _layer; } 45 | @Override public void paint (float dt) {} // nada 46 | @Override public void close () { _layer.close(); } 47 | 48 | protected final ImageLayer _layer; 49 | protected final Symbol _symbol; 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/gesture/GestureNode.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.gesture; 7 | 8 | import playn.scene.Touch; 9 | import pythagoras.f.Point; 10 | 11 | /** 12 | * A node in the history of the current user gesture. Events that spawn a new node: 13 | * * User touches a finger to the display (START) 14 | * * User removes a finger from the display (END) 15 | * * User moves far enough to trigger a drag in a new direction (MOVE) 16 | * * User stops dragging long enough to be considered "still" (PAUSE) 17 | * * User cancels a touch (CANCEL) 18 | */ 19 | public class GestureNode 20 | { 21 | public enum Type { START, END, MOVE, PAUSE, CANCEL } 22 | 23 | /** A timestamp for this node. */ 24 | public final double timestamp; 25 | /** The state change that caused the registration of this node. */ 26 | public final Type type; 27 | /** The touch event for this node. */ 28 | public final Touch.Event touch; 29 | /** The local location of the touch event in this node. */ 30 | public final Point location; 31 | 32 | public GestureNode (double timestamp, Type type, Touch.Interaction iact) { 33 | this(timestamp, type, iact.event, new Point(iact.local)); 34 | } 35 | 36 | public GestureNode (double timestamp, Type type, Touch.Event touch, Point location) { 37 | this.timestamp = timestamp; 38 | this.type = type; 39 | this.touch = touch; 40 | this.location = location; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/test/java/tripleplay/util/BagTest.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import java.util.HashSet; 9 | import java.util.Set; 10 | 11 | import org.junit.*; 12 | import static org.junit.Assert.*; 13 | 14 | public class BagTest 15 | { 16 | @Test public void testAddContainsRemove () { 17 | Bag bag = Bag.create(); 18 | for (int ii = 15; ii < 35; ii++) { 19 | bag.add(ii); 20 | } 21 | assertEquals(35-15, bag.size()); 22 | for (int ii = 0; ii < 50; ii++) { 23 | assertEquals(ii >= 15 && ii < 35, bag.contains(ii)); 24 | } 25 | for (int ii = 0; ii < 50; ii++) { 26 | assertEquals(ii >= 15 && ii < 35, bag.remove(ii)); 27 | } 28 | assertEquals(0, bag.size()); 29 | bag.add(3); 30 | bag.add(5); 31 | bag.add(9); 32 | assertEquals((Integer)9, bag.removeLast()); 33 | assertEquals((Integer)5, bag.removeLast()); 34 | assertEquals((Integer)3, bag.removeLast()); 35 | assertEquals(0, bag.size()); 36 | } 37 | 38 | @Test public void testIterator () { 39 | Bag bag = Bag.create(); 40 | Set values = new HashSet(); 41 | values.add(5); 42 | values.add(10); 43 | values.add(25); 44 | 45 | for (Integer elem : values) bag.add(elem); 46 | assertEquals(values.size(), bag.size()); 47 | for (Integer elem : bag) assertTrue(values.remove(elem)); 48 | assertTrue(values.isEmpty()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /java-lwjgl2/src/main/java/tripleplay/platform/JavaNativeOverlay.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.platform; 7 | 8 | import javax.swing.JComponent; 9 | 10 | import pythagoras.f.IRectangle; 11 | 12 | /** 13 | * Basic machinery for managing a java native child view. 14 | */ 15 | public class JavaNativeOverlay implements NativeOverlay 16 | { 17 | /** Swing component that is being overlaid. */ 18 | public final JComponent component; 19 | 20 | /** 21 | * Creates a new java native overlay for the given component. 22 | */ 23 | public JavaNativeOverlay (JavaTPPlatform plat, JComponent component) { 24 | _plat = plat; 25 | this.component = component; 26 | } 27 | 28 | @Override public void setBounds (IRectangle bounds) { 29 | component.setBounds((int)bounds.x(), (int)bounds.y(), 30 | (int)bounds.width(), (int)bounds.height()); 31 | } 32 | 33 | @Override public void add () { 34 | if (component.getParent() == null) { 35 | _plat.addOverlay(this); 36 | didAdd(); 37 | } 38 | } 39 | 40 | @Override public void remove () { 41 | if (component.getParent() != null) { 42 | _plat.removeOverlay(this); 43 | didRemove(); 44 | } 45 | } 46 | 47 | /** Called if the view is added to the root. */ 48 | protected void didAdd () {} 49 | 50 | /** Called if the view is removed from the root. */ 51 | protected void didRemove () {} 52 | 53 | protected final JavaTPPlatform _plat; 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/flump/KeyframeData.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.flump; 7 | 8 | import pythagoras.f.IPoint; 9 | 10 | public class KeyframeData 11 | { 12 | public final int index; 13 | public final int duration; 14 | public final String label; 15 | 16 | public final IPoint loc; 17 | public final IPoint scale; 18 | public final IPoint skew; 19 | public final IPoint pivot; 20 | 21 | public final boolean visible; 22 | public final float alpha; 23 | public final boolean tweened; 24 | public final float ease; 25 | 26 | public KeyframeData (int index, int duration, String label, 27 | IPoint loc, IPoint scale, IPoint skew, IPoint pivot, 28 | boolean visible, float alpha, boolean tweened, float ease, 29 | String ref) { 30 | this.index = index; 31 | this.duration = duration; 32 | this.label = label; 33 | this.loc = loc; 34 | this.scale = scale; 35 | this.skew = skew; 36 | this.pivot = pivot; 37 | this.visible = visible; 38 | this.alpha = alpha; 39 | this.tweened = tweened; 40 | this.ease = ease; 41 | // Library resolves _symbol once everything has been loaded 42 | _symbolName = ref; 43 | } 44 | 45 | /** 46 | * The symbol on this keyframe, if any. 47 | */ 48 | public Symbol symbol () { 49 | return _symbol; 50 | } 51 | 52 | protected Symbol _symbol; 53 | protected String _symbolName; 54 | } 55 | -------------------------------------------------------------------------------- /plugins/convert-flump-libs/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.threerings 6 | tripleplay-plugins 7 | 2.1-SNAPSHOT 8 | 9 | 10 | tripleplay-convert-flump-libs 11 | maven-plugin 12 | 13 | TP Convert Flump Libs Plugin 14 | Converts Flump libraries into binary format. 15 | 16 | 17 | 18 | ${project.groupId} 19 | tripleplay 20 | ${project.version} 21 | compile 22 | 23 | 24 | 25 | 26 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /demo/java-lwjgl2/src/main/java/tripleplay/demo/TripleDemoJava.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo; 7 | 8 | import java.util.List; 9 | 10 | import com.google.common.collect.Lists; 11 | 12 | import playn.core.Image; 13 | import playn.java.JavaPlatform; 14 | import playn.java.LWJGLPlatform; 15 | 16 | import tripleplay.platform.JavaTPPlatform; 17 | 18 | public class TripleDemoJava 19 | { 20 | public static void main (String[] args) { 21 | LWJGLPlatform.Config config = new LWJGLPlatform.Config(); 22 | config.appName = "Tripleplay Demo (LWJGL2)"; 23 | 24 | List mainArgs = Lists.newArrayList(); 25 | String size = "--size="; 26 | for (int ii = 0; ii < args.length; ii++) { 27 | if (args[ii].startsWith(size)) { 28 | String[] wh = args[ii].substring(size.length()).split("x"); 29 | config.width = Integer.parseInt(wh[0]); 30 | config.height = Integer.parseInt(wh[1]); 31 | } 32 | // else if (args[ii].equals("--retina")) config.scaleFactor = 2; 33 | else mainArgs.add(args[ii]); 34 | } 35 | 36 | TripleDemo.mainArgs = mainArgs.toArray(new String[0]); 37 | LWJGLPlatform plat = new LWJGLPlatform(config); 38 | JavaTPPlatform tpplat = new JavaTPPlatform(plat, config); 39 | tpplat.setIcon(loadIcon(plat)); 40 | new TripleDemo(plat); 41 | plat.start(); 42 | } 43 | 44 | protected static Image loadIcon (JavaPlatform plat) { 45 | return plat.assets().getImageSync("icon.png"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/IconEffect.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import playn.scene.Layer; 9 | import react.RFuture; 10 | 11 | /** 12 | * Used to apply effects to an Icon. 13 | */ 14 | public abstract class IconEffect 15 | { 16 | /** Leaves well enough alone. */ 17 | public static final IconEffect NONE = new IconEffect() { 18 | @Override public Icon apply (Icon icon) { 19 | return icon; 20 | } 21 | }; 22 | 23 | /** 24 | * Creates an IconEffect that sets the alpha on the Icon's created layer. 25 | */ 26 | public static final IconEffect alpha (final float alpha) { 27 | return new IconEffect() { 28 | @Override public Icon apply (Icon icon) { 29 | return new Proxy(icon) { 30 | @Override public Layer render () { 31 | return super.render().setAlpha(alpha); 32 | } 33 | }; 34 | } 35 | }; 36 | } 37 | 38 | /** Does the needful. */ 39 | public abstract Icon apply (Icon icon); 40 | 41 | /** Wrap an Icon for fiddling. */ 42 | protected static class Proxy implements Icon { 43 | protected Proxy (Icon icon) { _icon = icon; } 44 | @Override public float width () { return _icon.width(); } 45 | @Override public float height () { return _icon.height(); } 46 | @Override public Layer render () { return _icon.render(); } 47 | @Override public RFuture state () { return _icon.state(); } 48 | protected final Icon _icon; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /demo/java-swt/src/main/java/tripleplay/demo/TripleDemoJava.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo; 7 | 8 | import java.util.List; 9 | 10 | import com.google.common.collect.Lists; 11 | 12 | import playn.core.Image; 13 | import playn.java.JavaPlatform; 14 | import playn.java.SWTPlatform; 15 | 16 | import tripleplay.platform.SWTTPPlatform; 17 | 18 | public class TripleDemoJava 19 | { 20 | enum Toolkit { NONE, AWT, SWT } 21 | 22 | public static void main (String[] args) { 23 | JavaPlatform.Config config = new JavaPlatform.Config(); 24 | config.appName = "Tripleplay Demo (SWT)"; 25 | 26 | List mainArgs = Lists.newArrayList(); 27 | String size = "--size="; 28 | for (int ii = 0; ii < args.length; ii++) { 29 | if (args[ii].startsWith(size)) { 30 | String[] wh = args[ii].substring(size.length()).split("x"); 31 | config.width = Integer.parseInt(wh[0]); 32 | config.height = Integer.parseInt(wh[1]); 33 | } 34 | // else if (args[ii].equals("--retina")) config.scaleFactor = 2; 35 | else mainArgs.add(args[ii]); 36 | } 37 | 38 | TripleDemo.mainArgs = mainArgs.toArray(new String[0]); 39 | SWTPlatform plat = new SWTPlatform(config); 40 | SWTTPPlatform tpplat = new SWTTPPlatform(plat, config); 41 | tpplat.setIcon(loadIcon(plat)); 42 | new TripleDemo(plat); 43 | plat.start(); 44 | } 45 | 46 | protected static Image loadIcon (JavaPlatform plat) { 47 | return plat.assets().getImageSync("icon.png"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /demo/robovm/src/main/java/tripleplay/demo/TripleDemoRoboVM.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo; 7 | 8 | import org.robovm.apple.coregraphics.CGRect; 9 | import org.robovm.apple.foundation.NSAutoreleasePool; 10 | import org.robovm.apple.uikit.UIApplication; 11 | import org.robovm.apple.uikit.UIApplicationDelegateAdapter; 12 | import org.robovm.apple.uikit.UIApplicationLaunchOptions; 13 | import org.robovm.apple.uikit.UIInterfaceOrientationMask; 14 | import org.robovm.apple.uikit.UIScreen; 15 | import org.robovm.apple.uikit.UIWindow; 16 | 17 | import playn.robovm.RoboPlatform; 18 | 19 | public class TripleDemoRoboVM extends UIApplicationDelegateAdapter { 20 | 21 | @Override 22 | public boolean didFinishLaunching (UIApplication app, UIApplicationLaunchOptions launchOpts) { 23 | // create a full-screen window 24 | CGRect bounds = UIScreen.getMainScreen().getBounds(); 25 | UIWindow window = new UIWindow(bounds); 26 | 27 | // configure and create the PlayN platform 28 | RoboPlatform.Config config = new RoboPlatform.Config(); 29 | config.orients = UIInterfaceOrientationMask.All; 30 | RoboPlatform plat = RoboPlatform.create(window, config); 31 | 32 | // create and initialize our game 33 | new TripleDemo(plat); 34 | 35 | // make our main window visible (this starts the platform) 36 | window.makeKeyAndVisible(); 37 | addStrongRef(window); 38 | return true; 39 | } 40 | 41 | public static void main (String[] args) { 42 | NSAutoreleasePool pool = new NSAutoreleasePool(); 43 | UIApplication.main(args, null, TripleDemoRoboVM.class); 44 | pool.close(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/util/Ref.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | import react.Closeable; 9 | 10 | /** 11 | * Maintains a reference to a resource. Handles destroying the resource before releasing the 12 | * reference. 13 | */ 14 | public abstract class Ref 15 | { 16 | /** Creates a reference to a {@link Closeable} target. */ 17 | public static Ref create (T target) { 18 | Ref ref = new Ref() { 19 | @Override protected void onClear (T target) { 20 | target.close(); 21 | } 22 | }; 23 | ref.set(target); 24 | return ref; 25 | } 26 | 27 | /** Returns the current value of this reference, which may be null. */ 28 | public T get () { 29 | return _target; 30 | } 31 | 32 | /** Sets the current value of this reference, clearing any previously referenced object. 33 | * @return {@code target} to enabled code like: {@code F foo = fooref.set(new F())}. */ 34 | public T set (T target) { 35 | clear(); 36 | _target = target; 37 | return target; 38 | } 39 | 40 | /** Clears the target of this reference. Automatically calls {@link #onClear} if the reference 41 | * contains a non-null target. */ 42 | public void clear () { 43 | if (_target != null) { 44 | T toBeCleared = _target; 45 | _target = null; 46 | onClear(toBeCleared); 47 | } 48 | } 49 | 50 | /** Performs any cleanup on the supplied target (which has been just cleared). */ 51 | protected abstract void onClear (T target); 52 | 53 | protected T _target; 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/util/Conflater.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.util; 7 | 8 | /** 9 | * Code shared by {@link Inflater} and {@code Deflater}. 10 | */ 11 | abstract class Conflater { 12 | 13 | protected static String toHexString (int value, int ncount) { 14 | char[] data = new char[ncount]; 15 | for (int ii = ncount-1; ii >= 0; ii--) { 16 | data[ii] = HEX_CHARS.charAt(value & 0xF); 17 | value >>>= 4; 18 | } 19 | return new String(data); 20 | } 21 | 22 | protected static int fromHexString (String buf, int offset, int ncount) { 23 | int value = 0; 24 | for (int ii = offset, ll = offset+ncount; ii < ll; ii++) { 25 | value <<= 4; 26 | char c = buf.charAt(ii); 27 | int nibble = (c >= 'A') ? (10+c-'A') : (c-'0'); 28 | value |= nibble; 29 | } 30 | if (ncount == 2 && value > Byte.MAX_VALUE) value -= 256; 31 | else if (ncount == 4 && value > Short.MAX_VALUE) value -= 65536; 32 | return value; 33 | } 34 | 35 | protected static final String HEX_CHARS = "0123456789ABCDEF"; 36 | 37 | // used for variable length int encoding (by Inflater/Deflater) 38 | protected static final String VARABS = 39 | "\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO"; // ! intentionally omitted 40 | protected static final String VARCONT = 41 | "PQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}"; // ~ intentionally omitted 42 | protected static final int BASE = VARABS.length(); 43 | protected static final char ABS0 = VARABS.charAt(0), CONT0 = VARCONT.charAt(0); 44 | protected static final char NEG_MARKER = '!'; 45 | } 46 | -------------------------------------------------------------------------------- /demo/assets/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | com.threerings 6 | tripleplay-demo 7 | 2.1-SNAPSHOT 8 | 9 | 10 | tripleplay-demo-assets 11 | jar 12 | TP Demo Assets 13 | 14 | 15 | 17 | 18 | com.threerings 19 | tripleplay-tools 20 | ${project.version} 21 | true 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.codehaus.mojo 29 | exec-maven-plugin 30 | 1.4.0 31 | 32 | 33 | process-resources 34 | 35 | java 36 | 37 | 38 | 39 | 40 | tripleplay.tools.FramePacker 41 | 42 | ${basedir}/src/main/unpacked/assets/images/orb_burst_202x204.png 43 | ${project.build.outputDirectory}/assets/images 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/effect/Alpha.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle.effect; 7 | 8 | import playn.core.Color; 9 | 10 | import tripleplay.particle.Effector; 11 | import tripleplay.util.Interpolator; 12 | import static tripleplay.particle.ParticleBuffer.*; 13 | 14 | /** 15 | * Adjust the alpha value of a particle. 16 | */ 17 | public class Alpha 18 | { 19 | /** 20 | * Returns an effector that updates the particle's alpha based on its age, as adjusted by the 21 | * supplied interpolator. The particle will be faded from alpha of one to zero. 22 | */ 23 | public static Effector byAge (Interpolator interp) { 24 | return byAge(interp, 1, 0); 25 | } 26 | 27 | /** 28 | * Returns an effector that updates the particle's alpha based on its age, as adjusted by the 29 | * supplied interpolator. In general you'd use {@code startAlpha} of 1 and {@code endAlpha} of 30 | * 0, but if you are doing uncommon things, you might use different values. 31 | */ 32 | public static Effector byAge (final Interpolator interp, 33 | final float startAlpha, float endAlpha) { 34 | final float rangeAlpha = endAlpha - startAlpha; 35 | return new Effector() { 36 | @Override public void apply (int index, float[] data, int start, float now, float dt) { 37 | float alpha = interp.apply( 38 | startAlpha, rangeAlpha, now - data[start + BIRTH], data[start + LIFESPAN]); 39 | float red = Color.decodeLower(data[start + ALPHA_RED]); 40 | data[start + ALPHA_RED] = Color.encode(alpha, red); 41 | } 42 | }; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/core/src/main/java/tripleplay/demo/particle/ParticleDemo.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.demo.particle; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.Random; 11 | 12 | import tripleplay.particle.Emitter; 13 | import tripleplay.particle.ParticleBatch; 14 | import tripleplay.ui.Background; 15 | import tripleplay.ui.Group; 16 | import tripleplay.ui.Label; 17 | import tripleplay.ui.Root; 18 | import tripleplay.ui.Style; 19 | import tripleplay.ui.layout.AxisLayout; 20 | import tripleplay.util.Randoms; 21 | 22 | import tripleplay.demo.DemoScreen; 23 | 24 | public abstract class ParticleDemo extends DemoScreen 25 | { 26 | @Override public void showTransitionCompleted () { 27 | super.showTransitionCompleted(); 28 | ParticleBatch batch = new ParticleBatch(graphics().gl); 29 | closeOnHide(batch); 30 | createParticles(batch, _rando); 31 | } 32 | 33 | @Override public void hideTransitionStarted () { 34 | super.hideTransitionStarted(); 35 | for (Emitter emitter : _emitters) emitter.layer.close(); 36 | _emitters.clear(); 37 | } 38 | 39 | @Override protected Group createIface (Root root) { 40 | return new Group(AxisLayout.vertical(), Style.BACKGROUND.is(Background.solid(0xFF000000))); 41 | } 42 | 43 | protected abstract void createParticles (ParticleBatch batch, Randoms rando); 44 | 45 | protected void add (Emitter emitter) { 46 | layer.add(emitter.layer.setDepth(1)); 47 | _emitters.add(emitter); 48 | } 49 | 50 | protected final Randoms _rando = Randoms.with(new Random()); 51 | 52 | protected int _testIdx; 53 | protected List _emitters = new ArrayList(); 54 | } 55 | -------------------------------------------------------------------------------- /etc/bootstrap.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/particle/ParticleBatch.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.particle; 7 | 8 | import playn.core.GL20; 9 | import playn.core.Tile; 10 | import playn.core.TriangleBatch; 11 | 12 | /** 13 | * A custom batch designed for shading particles. 14 | */ 15 | public class ParticleBatch extends TriangleBatch 16 | { 17 | public ParticleBatch (GL20 gl) { 18 | super(gl); 19 | } 20 | 21 | public ParticleBatch prepare (Tile tile, int maxQuads) { 22 | setTexture(tile.texture()); 23 | _sx = tile.sx(); _sy = tile.sy(); 24 | _tx = tile.tx(); _ty = tile.ty(); 25 | // this doesn't actually change anything, it just makes sure we have space for a primitive 26 | // of the specified size and does some idempotent math 27 | beginPrimitive(maxQuads*4, maxQuads*6); 28 | return this; 29 | } 30 | 31 | /** Adds a particle quad to this batch. */ 32 | public void addParticle (float l, float t, float r, float b, float[] data, int ppos) { 33 | int vertIdx = beginPrimitive(4, 6), pstart = ppos + ParticleBuffer.M00; 34 | float[] verts = vertices; int offset = vertPos; 35 | float sx = _sx, sy = _sy, tx = _tx, ty = _ty; 36 | // bulk copy m00,m01,m10,m11,tx,ty,ar,gb then add quad info 37 | offset = add(verts, add(verts, offset, data, pstart, 8), l, t, sx, sy); 38 | offset = add(verts, add(verts, offset, data, pstart, 8), r, t, tx, sy); 39 | offset = add(verts, add(verts, offset, data, pstart, 8), l, b, sx, ty); 40 | offset = add(verts, add(verts, offset, data, pstart, 8), r, b, tx, ty); 41 | vertPos = offset; 42 | addElems(vertIdx, QUAD_INDICES, 0, QUAD_INDICES.length, 0); 43 | } 44 | 45 | protected float _sx, _sy, _tx, _ty; 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/tripleplay/ui/Button.java: -------------------------------------------------------------------------------- 1 | // 2 | // Triple Play - utilities for use in PlayN-based games 3 | // Copyright (c) 2011-2018, Triple Play Authors - All rights reserved. 4 | // http://github.com/threerings/tripleplay/blob/master/LICENSE 5 | 6 | package tripleplay.ui; 7 | 8 | import react.SignalView; 9 | 10 | /** 11 | * A button that displays text, or an icon, or both. 12 | */ 13 | public class Button extends AbstractTextButton