threerings / tripleplay

Utilities for use in PlayN-based games.
Other
92 stars 32 forks source link

Java native text fields don't support animation #32

Open jamie-threerings opened 11 years ago

jamie-threerings commented 11 years ago

I noticed in the demo after enabling the java platform, going into and out of the general tab shows the text fields fixed in place.

roguenet commented 11 years ago

Bruno added a method to help with this: Field.updateNativeFieldBounds(). The problem is that the Field itself doesn't get re-laid out if the container its in doesn't change dimensions or style properties, and the Field only knows to move its native associate if it gets told to lay out. updateNativeFieldBounds() is kind of a band-aid. I'm not sure what the real answer is.

roguenet commented 11 years ago

Also worth noting: this is not specific to the java native fields. iOS fields would have the same problem.

samskivert commented 11 years ago

"I told the Doctor, 'It hurts when I do this.'" "The Doctor said, 'Then don't do that.'"

There will always be a zillion rough edges when trying to magically keep a native field "in sync" with the scene graph that is hackily trying to pretend that the native field is a part of it.

Games will just have to work around the original sin of native component hackery with more hackery.

In the specific case of the screen transitions (which are definitely not the only place where native component rough edges will show), I plan to rewrite them to use the forthcoming "capture a scene graph into a texture" mechanism. This will, in theory, make this particular problem go away because the non-native Field will draw itself into the texture in lieu of the native field (and in theory it looks exactly the same), and then the whole scene graph (including the native field) will be destroyed and replaced by the big texture snapshot and the big texture snapshot will be used for the transition. This works around other issues like the fact that if you have a scene that contains clipped groups, FlipTransition and RotateYTransition don't work because they try to render the clipped group through a non-2D transform, which doesn't work.

roguenet commented 11 years ago

There's also the Field.FULLTIME_NATIVE_FIELD stye. I made it default to true for reasons that I no longer remember. Certainly, setting it to false for a field you want to animate will help a lot. Perhaps the default should be changed.