package com.eje_c.meganekko.sample;

import android.animation.ObjectAnimator;

import com.eje_c.meganekko.Frame;
import com.eje_c.meganekko.Meganekko;
import com.eje_c.meganekko.MeganekkoApp;
import com.eje_c.meganekko.SceneObject;
import com.eje_c.meganekko.utility.Log;

import ovr.JoyButton;

public class MyApp extends MeganekkoApp {
    private static final String TAG = "MGN";
    private SceneObject obj;

    public MyApp(Meganekko meganekko) {
        super(meganekko);

        setSceneFromXML(R.xml.scene);
        obj = getScene().findObjectById(R.id.myObject);
    }

    @Override
    public void update() {
        super.update();
//        Log.d(TAG, "update");

        Frame frame = getFrame();
        final int buttonPressedBits = frame.getButtonPressed();
        if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_TOUCH_SINGLE)) {
            ObjectAnimator anim = ObjectAnimator.ofFloat(obj, "opacity", 1, 0, 1);
            animate(anim, null);
        } else if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_TOUCH_DOUBLE)) {
            recenter();
        }

        if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_SWIPE_UP)) {
            ObjectAnimator anim = ObjectAnimator.ofFloat(obj.getTransform(), "positionY", obj.getTransform().getPositionY(), obj.getTransform().getPositionY() + 1.0f);
            animate(anim, null);
        } else if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_SWIPE_DOWN)) {
            ObjectAnimator anim = ObjectAnimator.ofFloat(obj.getTransform(), "positionY", obj.getTransform().getPositionY(), obj.getTransform().getPositionY() - 1.0f);
            animate(anim, null);
        } else if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_SWIPE_FORWARD)) {
            ObjectAnimator anim = ObjectAnimator.ofFloat(obj.getTransform(), "positionZ", obj.getTransform().getPositionZ(), obj.getTransform().getPositionZ() - 1.0f);
            animate(anim, null);
        } else if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_SWIPE_BACK)) {
            ObjectAnimator anim = ObjectAnimator.ofFloat(obj.getTransform(), "positionZ", obj.getTransform().getPositionZ(), obj.getTransform().getPositionZ() + 1.0f);
            animate(anim, null);
        }
    }

    @Override
    public void shutdown() {
        Log.d(TAG, "shutdown");
    }

    @Override
    public void onResume() {
        Log.d(TAG, "resumed");
    }

    @Override
    public void onPause() {
        Log.d(TAG, "paused");
    }
}

@@ -266,16 +266,43 @@
 y.Log;%0A%0A
+import org.joml.Vector3f;%0A%0A
 import o
@@ -1124,91 +1124,621 @@
     
-%7D%0A%0A        if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_SWIPE_UP)) %7B%0A
+    obj.animate()%0A                    .scaleBy(new Vector3f(1.5f, 1, 1))%0A                    .duration(1000)%0A                    .rotateBy(0.5f, 0.5f, 0)%0A                    .onEnd(new Runnable() %7B%0A                        @Override%0A                        public void run() %7B%0A                            System.out.println(%22End%22);%0A                        %7D%0A                    %7D)%0A                    .start(this);%0A        %7D%0A%0A        if (JoyButton.contains(buttonPressedBits, JoyButton.BUTTON_SWIPE_UP)) %7B%0A            obj.animate().moveBy(new Vector3f(0, 1, 0)).start(this);%0A%0A            // Equivalent animation%0A//
     
@@ -1893,32 +1893,34 @@
 ionY() + 1.0f);%0A
+//
             anim
@@ -2021,24 +2021,133 @@
 PE_DOWN)) %7B%0A
+            obj.animate().moveBy(new Vector3f(0, -1, 0)).start(this);%0A%0A            // Equivalent animation%0A//
             
@@ -2294,32 +2294,34 @@
 ionY() - 1.0f);%0A
+//
             anim
@@ -2425,24 +2425,133 @@
 FORWARD)) %7B%0A
+            obj.animate().moveBy(new Vector3f(0, 0, -1)).start(this);%0A%0A            // Equivalent animation%0A//
             
@@ -2698,32 +2698,34 @@
 ionZ() - 1.0f);%0A
+//
             anim
@@ -2826,24 +2826,132 @@
 PE_BACK)) %7B%0A
+            obj.animate().moveBy(new Vector3f(0, 0, 1)).start(this);%0A%0A            // Equivalent animation%0A//
             
@@ -3106,16 +3106,18 @@
  1.0f);%0A
+//
         

Update sample