threerings / playn Goto Github PK
View Code? Open in Web Editor NEWLegacy 1.x version of PlayN library.
Home Page: http://playn.io/
License: Apache License 2.0
Legacy 1.x version of PlayN library.
Home Page: http://playn.io/
License: Apache License 2.0
Is gamepad support planned for playn?
I can propose an API and work on java and html implementation...
Currently this is how GroupLayerImpl looks like
/** This group's children. */
public List<L> children = new ArrayList<L>();
/**
* @return the index into the children array at which the layer was inserted (based on depth).
*/
public int add(GroupLayer self, L child) {
// if this child has equal or greater depth to the last child, we can append directly and avoid
// a log(N) search; this is helpful when all children have the same depth
int count = children.size(), index;
if (count == 0 || children.get(count-1).depth() <= child.depth()) {
index = count;
} else {
// otherwise find the appropriate insertion point via binary search
index = findInsertion(child.depth());
}
// remove the child from any existing parent, preventing multiple parents
if (child.parent() != null) {
child.parent().remove(child);
}
children.add(index, child);
child.setParent(self);
child.onAdd();
return index;
}
There might be a potential issue of getting ArrayIndexOutOfBound when doing
children.add(index, child);
let's say the children is 5 in size, and the last one children[4] has a depth less than the child we are adding, so the index will be 5 and then we try to do
children.add(5, child)
we'll get ArrayIndexOutOfBound exception, it says in the javadoc of ArrayList
IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())
Possible fix, if this is an issue would be instead of
children.add(index, child);
we do
if (index >= children.size()) {
children.add(child); // this will add child to the last in the list anyway
}
else {
children.add(index, child);
}
Can some developer verify this please?
Hi,
With 1.9-alpha1 / robovm / iOS 8
Canvas.setFillColor
has no effect on the written text when using Canvas.fillText
. Only black is supported as foreground color which makes text invisible on black background.
JavaStorage saves to a temporary directory (/tmp on Linux) which means it's wiped after a reboot. It should probably go in the current or home directory.
Android devices with Vivante GPU
(Vivante GC800, GC1000, GC4000)
are not working with the Tests app
some phones/tablets with Vivante GPUs:
Samsung S5690 Galaxy Xcover
Bq Pascal 2
Samsung Galaxy Tab 3
Alcatel onetouch T10
Ainol Novo 10 Hero 2
I am keen on learning this tool but can't find any documentation on the wiki or on google even. Would be great to have somewhere to start.
If I have missed something just let me know! Thanks
I just receive this error on the java backend after upgrading my game to a 1.5-SNAPSHOT, it was working fine with 1.4.
Is this error a result of my hardware, wich is kind of dated, or there was some change that could be triggering this?
I can't find out how to detect keyboard modifier clicks, if there isn't a way to do it, perhaps it could be implemented since its a very common feature required in game design.
I would have expected the modifiers to be returned in the Keyboard.Event
Cheers!
I am trying port my application in which the game is integrated as a view controller. The game view will be shown as blank at the second time we run the game.
It is probably caused by GL drawing that is not shutdown completely. I did not find the equivalent function of gameView.Stop() in the Xamarin implementation.
The following is the code I used:
public class Demo extends UIApplicationDelegateAdapter {
private UIWindow window;
@Override
public boolean didFinishLaunching(UIApplication app, UIApplicationLaunchOptions launchOpts) {
window = new UIWindow(UIScreen.getMainScreen().getBounds());
window.setRootViewController(new MainController());
window.makeKeyAndVisible();
return true;
}
public static void main(String[] args) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(args, null, Demo.class);
pool.close();
}
}
public class MainController extends UIViewController {
public MainController() {
super();
UIButton button = new UIButton();
button.setTitle("Run", UIControlState.Normal);
setView(button);
button.addOnTouchUpInsideListener(new OnTouchUpInsideListener() {
@Override
public void onTouchUpInside(UIControl control, UIEvent event) {
runGame();
}
});
}
private void runGame() {
RoboPlatform.Config config = new RoboPlatform.Config();
config.embedded = true;
RoboPlatform platform = (RoboPlatform) PlayN.platform();
platform = RoboPlatform.register(UIApplication.getSharedApplication(), UIApplication.getSharedApplication()
.getWindows().get(0), config);
// reference this to avoid GC collection.
addStrongRef(platform);
// Start the game
Game game = new TheGame(this);
PlayN.run(game);
// We have to manually active the platform since it is embedded in our app.
platform.activate();
}
private static class TheGame extends Game.Default {
final private UIViewController from;
public TheGame(UIViewController from) {
super(30);
this.from = from;
}
@Override
public void init() {
CanvasImage image = PlayN.graphics().createImage(200, 200);
image.canvas().setFillColor(Colors.RED).fillRect(0, 0, 200, 200);
ImageLayer layer = PlayN.graphics().createImageLayer(image);
layer.addListener(new Pointer.Adapter() {
@Override
public void onPointerEnd(Event event) {
UIApplication.getSharedApplication().getWindows().get(0).setRootViewController(from);
RoboPlatform platform = (RoboPlatform) PlayN.platform();
platform.terminate();
PlayN.setPlatform(null);
from.removeStrongRef(platform);
}
});
PlayN.graphics().rootLayer().addAt(layer, 20, 20);
}
}
}
I'm trying to show some image layers in a group when this group is clicked:
groupLayer.addListener(new Pointer.Adapter() {
@Override
public void onPointerStart(Pointer.Event event) {
//set some child layer as visible
}
});
The onPointerStart callback is called only if setPropagateEvents is set to true and if a child is clicked.
There is a problem when running a PlayN application on Android and onPause getting called due to visibility changed to invisible, for example when pressing the power button to lock the screen or if another app takes focus.
When this happens platform.graphics().ctx.onSurfaceLost(); will get called from GameViewGL.onPause(), which will clear all textures. When we resume after this the game looks ok, but as soon as the garbage collector runs the screen will turn black.
We have tried this with a blank project and it still occurs, though a bit harder to reproduce due to the garbage collector not being so interested in running when we use so little memory.
A temporary solution for us has been to add platform.graphics().ctx.onSurfaceCreated(); to GameViewGL.onResume(), don't know if this could create other problems though, if so we haven't seen them yet.
We have traced the adding of the platform.graphics().ctx.onSurfaceLost() call in GameViewGL to the following commit
c4310a8#L2R142
Hi,
I added support to openGL 2.0 ES on PlayN \o/
To do that I added 2 new files on java package (JavaGLES20 and JavaGLESContext).
I changed JavaImage(just a cast) and JavaGraphics (support to choose between normal and ES version) too.
Have you interest to get it on you project? I can send files to you :)
The big problem is get LWJGL ES version (because it is not on maven, you need to compile it by you self).
There are now missing dependencies that this version requires to build. I understand that this is legacy, but I'm sure some people are still using this version and need to be able to build it. The now missing dependencies and dependency changes are found here:
I commited the dependencies from my location maven repo there.
using play 1.5.1
as soon as I go for drawing anything on graphics(). it gives nullpointer exception with this warning
GPU/driver lacks sufficient vertex uniform vectors for QuadShader
[java] GPU/driver lacks sufficient vertex uniform vectors for QuadShader.
[java] Exception in thread "main" java.lang.NullPointerException
[java] at playn.java.JavaImage.draw(JavaImage.java:84)
[java] at playn.java.JavaAsyncImage.draw(JavaAsyncImage.java:32)
[java] at playn.java.JavaCanvas.drawImage(JavaCanvas.java:118)
[java] at playn.java.JavaCanvas.drawImage(JavaCanvas.java:105)
and the application goes into 'not responding' state(i m using window)
This is pretty easy to observe in the demo. Choose "Text Test" and click to enter a string with leading and trailing spaces, like " A ". Under java, just the "A" is rendered. Under ios, the " A" is rendered. Is it possible to make this consistent? It's causing problems for me in a styled text renderer in my app.
I'd prefer to include spaces in all rendering since that would allow the best control. Otherwise, I'd need to somehow measure a space and do special extra stuff during laying out each chunk, not pretty.
On a Nexus 5 device, my game, Ned et les maki, failed with QuadShader related errors:
W/playn (10726): Failed to create QuadShader: java.lang.RuntimeException: Failed to link program: --From Vertex Shader:
W/playn (10726): Error: uniform variables in vertex shader do not fit in 251 vectors.
W/playn (10726): --From Fragment Shader:
W/playn (10726): Error: uniform variables in vertex shader do not fit in 251 vectors.
Full log: http://pastebin.com/JzdC3RzN
here: https://github.com/threerings/playn/tree/master/tests/android
SoundTest buttons "Stop Loop Fanfare" and "Stop Loop Bling" does not works (can't stop looping sound).
Tested on mobile device and in Android emulator, same thing...
The wiki page for getting started still points at the source code on Google code. It should point at the Github source code instead.
Travis builds in response to commits, but doesn't publish its snapshots upstream. The one [current-version]-SNAPSHOT release is increasingly out of date, so things like tripleplay's travis build constantly fail.
(See also: tripleplay where I'm about to file a very similar issue since I have a TP-based project with a travis build that constantly fails thanks to both of these having out-of-date snapshots unless I pull cpu-wasting hackery such as https://github.com/deadmoose/bort/blob/ace9b8f05c7609210bb880b414f7d90fa81f5341/.travis.yml )
What is the best way to have a resizable window with Java version? A lot of gamers like to play with maximized windon instead of fullscreen.
I tried to overrides Game.Default methods, it work more or less, but it does not play well with layers other than ImmediateLayer:
@Override
public void init() {
Display.setResizable(true);
super.init();
}
@Override
public void paint(float alpha) {
PlayN.graphics().ctx().setSize(Display.getWidth(), Display.getHeight());
super.paint(alpha);
}
I remember things were changed to allow setScale(0), but it still causes the game to asplode during hit testing on the next tick:
2013/07/05 14:25:09:876 STDOUT Caused by: pythagoras.util.NoninvertibleTransformException: affine [+0.0 +0.0 +0.0 +0.0 +0.0+176.648]
2013/07/05 14:25:09:876 STDOUT at pythagoras.f.AffineTransform.inverseTransform(AffineTransform.java:332)
2013/07/05 14:25:09:876 STDOUT at playn.core.GroupLayerImpl.hitTest(GroupLayerImpl.java:121)
2013/07/05 14:25:09:876 STDOUT at playn.core.gl.GroupLayerGL.hitTestDefault(GroupLayerGL.java:152)
2013/07/05 14:25:09:876 STDOUT at playn.core.AbstractLayer.hitTest(AbstractLayer.java:275)
2013/07/05 14:25:09:877 STDOUT at playn.core.GroupLayerImpl.hitTest(GroupLayerImpl.java:124)
2013/07/05 14:25:09:877 STDOUT at playn.core.gl.GroupLayerGL.hitTestDefault(GroupLayerGL.java:152)
2013/07/05 14:25:09:877 STDOUT at tripleplay.ui.Element$1.hitTest(Element.java:45)
2013/07/05 14:25:09:877 STDOUT at playn.core.AbstractLayer.hitTest(AbstractLayer.java:275)
2013/07/05 14:25:09:878 STDOUT at playn.core.GroupLayerImpl.hitTest(GroupLayerImpl.java:124)
2013/07/05 14:25:09:878 STDOUT at playn.core.gl.GroupLayerGL.hitTestDefault(GroupLayerGL.java:152)
2013/07/05 14:25:09:878 STDOUT at playn.core.AbstractLayer.hitTest(AbstractLayer.java:275)
2013/07/05 14:25:09:878 STDOUT at playn.core.GroupLayerImpl.hitTest(GroupLayerImpl.java:124)
2013/07/05 14:25:09:879 STDOUT at playn.core.gl.GroupLayerGL.hitTestDefault(GroupLayerGL.java:152)
2013/07/05 14:25:09:879 STDOUT at playn.core.AbstractLayer.hitTest(AbstractLayer.java:275)
2013/07/05 14:25:09:879 STDOUT at playn.core.MouseImpl.onMouseMove(MouseImpl.java:119)
2013/07/05 14:25:09:879 STDOUT at playn.java.JavaMouse.update(JavaMouse.java:83)
2013/07/05 14:25:09:880 STDOUT at playn.java.JavaPlatform.run(JavaPlatform.java:263)
2013/07/05 14:25:09:880 STDOUT at playn.core.PlayN.run(PlayN.java:47)
2013/07/05 14:25:09:880 STDOUT at com.threerings.arcadians.client.java.ArcadiansGameJava.main(ArcadiansGameJava.java:42)
2013/07/05 14:25:09:880 STDOUT ... 6 more
It should be a matter of doing a determinant check in GroupLayerImpl.hitTest, and possibly Layer.parentToLayer.
Hi,
1.9-SNAPSHOT
robovm
iPhone 6 with iOS 8.1
Using the PlayN.net().get(url,callback)API the game hangs on the simulator and I saw the following stack several times (but not systematically) on the real device:
java.lang.NullPointerException
at playn.robovm.RoboNet$1.connectionDidFinishLoading$(RoboNet.java)
at org.robovm.apple.foundation.NSURLConnectionDataDelegate$ObjCProxy.$cb$connectionDidFinishLoading$(Unknown Source)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at metro.robovm.MetroRoboVM.main(MetroRoboVM.java)
What steps will reproduce the problem?
html module generated by playn maven archetype replies on gwt-maven-plugin to decide on the GWT version which will causes compilation error if more 1 version of gwt is in the classpath
What is the expected output? What do you see instead?
maven playn skeleton to be generated successfully without errors (eg. ClassNotFoundException)
What version of the product are you using? On what operating system?
PlayN from trunk, Windows, Linux
Please provide any additional information below.
Attached is a patch that will generate pom for html module with gwt version configured as maven property default to 2.4.0, and force gwt-maven-plugin to use the specific version as indicated by maven property.
Following are traces from maven log when using the -X parameters
[INFO] --- gwt-maven-plugin:2.3.0-2-playn:compile (default) @ mplyn1-html ---
[DEBUG] org.codehaus.mojo:gwt-maven-plugin:jar:2.3.0-2-playn:
[DEBUG] com.google.gwt:gwt-user:jar:2.3.0:runtime
[DEBUG] com.google.gwt:gwt-dev:jar:2.3.0:runtime
[DEBUG] org.apache.maven:maven-project:jar:2.0.9:compile
[DEBUG] org.apache.maven:maven-settings:jar:2.0.9:compile
gwt-maven-plugin decided to use gwt 2.3.0
[DEBUG] GWT SDK execution classpath :
...
[DEBUG] D:\maven_repo\com\googlecode\playn\playn-html\1.1-SNAPSHOT\playn-html-1.1-SNAPSHOT.jar
[DEBUG] D:\maven_repo\com\googlecode\playn\playn-core\1.1-SNAPSHOT\playn-core-1.1-SNAPSHOT.jar
[DEBUG] D:\maven_repo\com\googlecode\playn\playn-webgl\1.1-SNAPSHOT\playn-webgl-1.1-SNAPSHOT.jar
[DEBUG] D:\maven_repo\com\google\gwt\gwt-user\2.4.0\gwt-user-2.4.0.jar
[DEBUG] D:\maven_repo\javax\validation\validation-api\1.0.0.GA\validation-api-1.0.0.GA.jar
[DEBUG] D:\maven_repo\javax\validation\validation-api\1.0.0.GA\validation-api-1.0.0.GA-sources.jar
[DEBUG] D:\maven_repo\com\allen-sauer\gwt\voices\gwt-voices\2.1.3\gwt-voices-2.1.3.jar
...
but then for some reason it decided to include gwt 2.4.0 in the classpath too
This patch will force gwt-maven-plugin to always use the version specified in gwt.version property
diff --git a/archetype/src/main/resources/archetype-resources/html/pom.xml b/archetype/src/main/resources/archetype-resources/html/pom.xml
index 3261267..13b9331 100644
--- a/archetype/src/main/resources/archetype-resources/html/pom.xml
+++ b/archetype/src/main/resources/archetype-resources/html/pom.xml
@@ -16,6 +16,7 @@
<gwt.module>${package}.${gameName}</gwt.module>
<gwt.name>${rootArtifactId}</gwt.name>
Created one issue with PlayN site as well, but guess i should be cancelling that one.
Hi guys,
I know this is a very trivial patch, but it really helps me to get mvn eclipse:eclipse to work. Currently without the following mvn eclipse:eclipse failed with the following nasty error
Failed to execute goal org.apache.maven.plugins:maven-eclipse-plugin:2.8:eclipse (default-cli) on project playn-archetype
Guessing that it got some internal conflict when no maven eclipse plugin is specified. The fix is pretty simple, just add specify a version of maven eclipse plugin in playn/pom.xml would fix it.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.6</version>
<configuration>
<ajdtVersion>1.6</ajdtVersion>
</configuration>
</plugin>
If someone could help patch this in that'd be great, else people would have to manually put this in everything they do a git pull which could be rather annoying at times. Cheers
Hey wondering if there would be a way to load a GIF image and animate it? It makes sense that this could be possible with Java, but to have this work on HTML is probably not as straight forward? Anyway appreciate any help I can get!
I have this snippet of code:
float DUR = 600;
fanim.tweenScale(photo).to(0.25F).in(DUR).easeInOut();
fanim.tweenXY(photo).to(-10, 370).in(DUR).easeInOut();
fanim.tweenRotation(photo).to(-FloatMath.PI / 8).in(DUR);
fanim.addBarrier(333); // wait for the current animations to finish and then wait another 333 ms
fanim.tweenXY(photo).to(-300, 270).in(DUR).easeOutBack();
fanim.tweenRotation(photo).to(-3 * FloatMath.PI).in(DUR);
The desired behaviour is to scale, move and rotate the photo (an ImageLayer) all three at the same time, then afterwards wait 333 ms, then again move and rotate it out of the screen.
In Java this works ok, but when I export to HTML, it doesn't wait the 333 ms between the two sets of animations
I set up a minimal project in github that showcases the problem:
https://github.com/tulsidas/tripleplay-barrier-demo
The code is extracted from the game that originated the problem.
There is a standard animation moving a circle, and if you click anywhere, it will take a snapshot of the screen and animate it.
On the java version it works properly, the snapshot goes to the corner, waits ~3 seconds, then goes away, but on the HTML backend it goes to the corner and immediatly goes away (not waiting the ~3 seconds)
I tried it both in Chromium 37 and Firefox 31, same wrong behaviour in both.
Looking and debugging into the JS generated code (attached) it seems (I'm mostly guessing) that the noActiveAnims flag (line 7878) is being wrongfully set to true when the "main" anim finishes, hence removing the secondary anim (the snapshot one) from the queue, and that's why it never finishes the waiting
We find the following bug inside playn/html
, the reason of this bug is the code converts an array (the return value of the method soundController.getPreferredSoundTypes()
is an array) to a string directly, which will deliver the address of this array not the strings inside the array.
Path: playn/html/src/playn/html/HtmlAudio.java
Bug location: soundController.getPreferredSoundTypes()
line 61
Code:
void init() { HtmlPlatform.log.debug("Preferred sound type(s): " + soundController.getPreferredSoundTypes());
This is how setPathPrefix looks like currently
public void setPathPrefix(String prefix) {
if (prefix.startsWith("/") || prefix.endsWith("/")) {
throw new IllegalArgumentException("Prefix must not start or end with '/'.");
}
pathPrefix = prefix + "/";
}
Shouldn't it be something like instead
public void setPathPrefix(String prefix) {
if (prefix.startsWith("/") || prefix.endsWith("/")) {
throw new IllegalArgumentException("Prefix must not start or end with '/'.");
}
pathPrefix = prefix.length() > 0 ? prefix + "/" : prefix;
}
Say if i have my image in src/main/resources/images/myface.png and i do
assetManager().setPathPrefix("");
so i can do
assetManager().getImage("images/myface.png");
i'll get thrown with exception saying it cannot find '/images/myface.png'. internally it's trying to get the resource from
getClass().getClassLoader().getResource("/images/myface.png");
which should really be
getClass().getClassLoader().getResource("images/myface.png");
A game may not use all components provided by Platform.java, such as Audio , Net or Storage. Shall we make those components initialized lazily?
Silent games may exist, and I am working a case in which Audio is not used since no seeking is available and we need recording at the same time. Lazy initialzation also speeds up the startup although just a little.
Not sure those are in your designed use cases. If yes, I would like commit patches. If not, just close this issue.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.