Closed LimeJuice closed 12 years ago
hi limejuice,
unfortunately there is not really a nice way to use ani on android. the reason behind this is, that the registerDraw() mechanism of the processing core api was not ported to android and ani relies on that ... so to speak, ani is now able to hook into the draw loop cycle, see http://forum.processing.org/topic/android-api-changes-registering-methods-make-library-also-working-on-android and http://wiki.processing.org/w/Android#API_Changed.2C_Gone.2C_or_Forgotten
if registerDraw() is ported to android, ani should work out of the box ... and i don't want to create at the moment a workaround for this, because i am quite sure in the final processing 2.0 there will be a solution for this.
a dirty solution would be to mimic the registerDraw() mechanism in your sketch (if you wanna try it give me a shout)
hope this helps a bit. best, benedikt
Thanks for this information. I looking forward to having it working !!! Thanks
if you want you can write me an email via my contact details here: http://www.looksgood.de/log/contact/
and if you really want to give it a try then ... you have to get rid around the dependency of registerPre() to papplet. you could try to mimic the whole mechanism by overriding two specific functions, see example below ... but then you still have to port the whole register thing to your main sketch, which should be possible by a few copy & pastes from the processing source code.
but fist try the code below in android, if you get the printlns then it should be possible otherwise i see no chance (without hacking Ani).
please let me know waht you think. so long.
import de.looksgood.ani.*;
float x = 256; float y = 256;
void setup() { size(512,512); smooth(); noStroke();
// you have to call always Ani.init() first! Ani.init(this); }
void draw() { background(255); fill(0); ellipse(x,y,120,120); }
void mouseReleased() { // animate the variables x and y in 1.5 sec to mouse click position Ani.to(this, 1.5, "x", mouseX); Ani.to(this, 1.5, "y", mouseY); }
void registerPre(Object obj) { println("called from aniCore "+obj.toString()); }
void unregisterPre(Object obj) { // ... }
Hi,
thanks for this info, I am not feeling confident on modifying the processing source code... but I can give a try... I tryed your example in Android processing, it build and print correctly twice and then stop printing. I will have a look online on the way to add registerDraw().
Thanks
welcome. but you don't have to modify the source code of processing ...
you "just" have to port the registerDraw() thing to your sketch. i assume most of it, is copy and paste from the processing source to your sketch. sorry for not being clear.
Ok I tryed this at the end of my sketch:
void registerPre(Object obj) { println("called from aniCore "+obj.toString()); registerDraw(obj);
}
void unregisterPre(Object obj) { unregisterDraw(obj); }
//// FROM PROCESSING SOURCE CODE :
public void registerDraw(Object o) { registerNoArgs(drawMethods, "draw", o);
} public void unregisterDraw(Object o) { unregisterNoArgs(drawMethods, "draw", o); }
It crashes and tells me that : java.lang.RuntimeException: There is no public draw() method in the class de.looksgood.ani.Ani
I Guess I need to change registerNoArgs(drawMethods, "draw", o); with another function then "draw"
Am I on the right way ?
sorry was busy ... please try this code. does it run now on android? best benedikt
import de.looksgood.ani.*;
float x = 256; float y = 256;
ArrayList
void setup() { size(512, 512); smooth(); noStroke();
Ani.init(this);
anis = new ArrayList
void draw() { background(255); fill(0); ellipse(x, y, 120, 120);
updateAnis(); }
void mouseReleased() { // animate the variables x and y in 1.5 sec to mouse click position Ani.to(this, 1.5, "x", mouseX); Ani.to(this, 1.5, "y", mouseY); }
// ------------------------------------------- void updateAnis(){ if (anis.size() < 1) return; for (Ani i : anis) { i.pre(); }
if(anisToUnregister.size() > 0) { for (int i=0; i < anisToUnregister.size(); i++) { anis.remove(i); anisToUnregister.remove(i); println("removed"); } } println(anis.size()); }
void registerPre(Object obj) { println("called from aniCore "+obj.toString()); anis.add( (Ani)obj ); }
void unregisterPre(Object obj) { int index = anis.indexOf( (Ani)obj ); anisToUnregister.add(index); }
Not yet, I got an error at this point:
for (Ani i : anis) { i.pre(); }
here the error associate : required: Ani Found : Object
If I remove these lines, it build and run normaly, no animation happens if a touch the screen but the println(anis.size()); print " 2 ".
Thanks
hmm ... strange. what about this one?
import de.looksgood.ani.*;
float x = 256;
float y = 256;
ArrayList<Ani> anis;
ArrayList anisToUnregister;
void setup() {
size(512, 512);
smooth();
noStroke();
Ani.init(this);
anis = new ArrayList<Ani>();
anisToUnregister = new ArrayList();
}
void draw() {
background(255);
fill(0);
ellipse(x, y, 120, 120);
updateAnis();
}
void mouseReleased() {
// animate the variables x and y in 1.5 sec to mouse click position
Ani.to(this, 1.5, "x", mouseX);
Ani.to(this, 1.5, "y", mouseY);
}
// -------------------------------------------
void updateAnis(){
if (anis.size() == 0) return;
for (int i=0; i < anis.size(); i++) {
Ani aniTmp = (Ani)anis.get(i);
aniTmp.pre();
}
if(anisToUnregister.size() > 0) {
for (int i=0; i < anisToUnregister.size(); i++) {
anis.remove(i);
anisToUnregister.remove(i);
println("removed");
}
}
println(anis.size());
}
void registerPre(Object obj) {
anis.add( (Ani)obj );
}
void unregisterPre(Object obj) {
int index = anis.indexOf( (Ani)obj );
anisToUnregister.add(index);
}
Marvelous ! It works perfectly on the device ! Thanks for your help, and I hope this discussion will help other people developing on Processing Android as well.
thanks! and nice to hear :) i am going to include the sketch to the examples of the ani distribution. btw. if there is something to see from your side ... i am always curious what others do with ani.
so long + good luck!
Hi, I will send you a video of my work with Ani soon. Thanks again
cool! looking forward to it :)
Hello,
I am wondering if there is any ways to use Ani on Android devices? I tryed with the examples, they build and launch normaly on the device, but then no animation are displayed...
Thanks