@Override
protected Group createIface() {
animGlayer = graphics().createGroupLayer();
layer.addAt(animGlayer, 100, 50);
fullSheetHeight = 320;
fullSheetWidth = 1600;
oneImageWidth = fullSheetWidth / 10;
oneImageHeight = fullSheetHeight / 2;
animLayer = graphics().createImageLayer();
layer.add(animLayer);
Image image = assets().getImage("images/myAlienSprites.png");
image.addCallback(new Callback<Image>() {
public void onSuccess(Image image) {
Region swimAlien = image.subImage(0, 0, fullSheetWidth, oneImageHeight);
SimpleFrames frames = new SimpleFrames(swimAlien, oneImageWidth, oneImageHeight);
swimLeftFlipbook = new Flipbook(frames, 100);
anim.repeat(animLayer).flipbook(animLayer, swimLeftFlipbook);
anim.add(animGlayer, animLayer);//(layer, animLayer);
animLayer.setOrigin(oneImageWidth / 2, 0);
}
@Override
public void onFailure(Throwable cause) {
PlayN.log().warn("dood"+cause.getMessage());
}
});
animLayer.addListener(new Pointer.Adapter() {
public void onPointerStart(Pointer.Event event) {
//anim.flipbook(animLayer, swimLeftFlipbook).then()....? new runnable? destroy the layer? hide it?
//proper code to halt the animation.
}
});
return null;
}
Here are some snippets, let me know if I'm being unintelligible. It happens. Also, thanks in advance for any help! :)
To cancel a animation which is being repeated you will have to fetch the handle on the repeat function before you start queuing up the animations on it.
At least this is the way that we are doing it.
Hope that it makes sense.
To cancel a animation which is being repeated you will have to fetch the handle on the repeat function before you start queuing up the animations on it.
Animation a = _anim.repeat(layer);
Handle h = a.handle();
a. ... queue up other animations;
h.cancel();
Probably errors in the code, writing from memory.
Will try it again using latest tp.
Animation.Repeat cr = _anim.add(new Animation.Repeat(jumpLayer));
final Handle h = cr.handle();
cr.then().tweenX(jumpLayer).to(300).in(1960).then().tweenX(jumpLayer).to(100).in(1960);
_timer.after(5000, new Runnable() {
@Override
public void run() {
h.cancel();
}
});
final Handle h = _anim.repeat(jumpLayer).tweenX(jumpLayer).to(300).in(1960).then().tweenX(
jumpLayer).to(100).in(1960).handle();
_timer.after(5000, new Runnable() {
@Override
public void run() {
h.cancel();
}
});
THIS CODE DOES NOT WORK:
final Handle h = _anim.repeat(jumpLayer).tweenX(jumpLayer).to(300).in(1960).then().tweenX(
jumpLayer).to(100).in(1960).handle();
_timer.after(5000, new Runnable() {
@Override
public void run() {
h.cancel();
}
});
Works like a charm, awesome!
We use the tp animation system to animate a lot of in game stuff in the game which we currently are developing, and we haven't encountered any giant obstacles yet. Patrolling monsters, player animation, etc. Flipbook+tween(Value) seems nice for a lot of stuff. We haven't started to think about nice looking transitions yet, and when we do maybe we need to find some other way to do our animations.
What do you use at OOO? Flashbang? Or maybe something more secret and closed source :)
We have also been looking a little on Flump, and it looks very interesting. But it looks like one have to buy some Flash animation tool to create useable animation data.
// if we have no next animation, return our overflow
_current = _current.next();
if (_current == null) return remain;
(around line 408).
I found that If I open up the Animator class and add an extra if statement to see if current happened to have been unset after the while loop was entered, assuming 0 frames remaining, I just return 0.
while (remain <= 0) {
// if we've been canceled, none remaining
if(_current == null) return 0;
// if we have no next animation, return our overflow
_current = _current.next();
if (_current == null) return remain;
This fixes the exception and I think gets most of what I'm looking for, in that I get to keep my imageLayer around, I can just cancel it at will and replace the flipbook in it with a different one. For instance, I can do something like this:
alien.setAnimation(anim, rotatingFramesFlipBook).then().action(new Runnable(){
@Override
public void run() {
alien.setAnimation(anim, swimLeftFlipbook);
}
});
It looks like it's possible to get a null pointer in the while loop, possibly because of the current.apply()?
I pulled down latest & built. Got the change. However, if I try what you suggested, either destroying & recreating or simply canceling, i get a null pointer exception in the Animation class.
alien.setAnimation(anim, rotatingFramesFlipBook).then().action(new Runnable(){
@Override
public void run() {
alien.setAnimation(anim, swimLeftFlipbook);
}
});
I'm trying to do something like:
- animateLeft when moving left.
- Cue turn animation right before/during turning around.
- After turn animation is complete, we're moving "right". so play the rightMotion animation.
The whole time there's one animation constantly running, whether left, right, or rotate. Lemme know if there's a better way to accomplish it. :)
if (transition == null) {_current = anim.repeat(layer).flipbook(_blayer, repeated);} else {_current = anim.flipbook(_blayer, transition).then().repeat(layer).flipbook(_blayer, repeated);}
--
Flump is designed for studios (like ours) that are transitioning away from making Flash games, and who have a bunch of artists who are comfortable making animations using the Flash Authoring Tool and who would like to keep doing that, instead of learning some totally new tool which probably totally sucks compared to the (expensive, commercial) Flash Authoring Tool.Letting your artists use the tools they're comfortable with tends to more than pay for the cost of the tool. We could force all of our artists to use Gimp instead of Photoshop, and within a week or two we will have spent the cost of the Photoshop licenses in lost productivity.
Just out of curiosity. If you were starting up a company with only two guys who are mainly coders and who are trying to fill all the roles in the game making process, and these guys are open to switch to which ever coding language and whatever tools to fulfil their mission. What languages and tools would you use to be able to get into creating the actual games as quick as possible and release them on Android, iOS and HTML5?
As of now we are using PlayN, Inkscape, Gimp, Blender and Garageband. But sometimes I wonder if it wouldn't be better to just go with Unity or something more streamlined. But then we would loose HTML5, open source and get some extra licensing costs.
But seeing that LibGDX uses Java, is more mature in many ways and will support Android, iOS and HTML. Wouldn't it be better if everyone on PlayN switched to LibGDX instead? Boosting the progress of it. Or why did you guys on OOO choose PlayN over LibGDX?