Java Bridge Thread

327 views
Skip to first unread message

M. Hossein Amerkashi

unread,
Aug 24, 2011, 10:08:55 AM8/24/11
to appto...@googlegroups.com
[1] Original posting on AI Bridge by Mark Friedman can be found HERE

Some tutorials on using Original Java Bridge (above) can be found HERE

[1] Has dependency on external libraries and also makes the app much larger. Ryan is working on an updated standalone version. I have also been working on an standalone version (AiBridge.jar) that can be found HERE. This version eliminates need for external libraries and I have added / updated functionalities where I saw a need.

-Hossein.


PavementPilot

unread,
Sep 9, 2011, 4:52:56 AM9/9/11
to appto...@googlegroups.com
Why cant anyone just write instructions in plain english, such as open cmd and change directory too... and type .... etc. I have having a hell of a time trying to get this BridgeToJava to load or download or whatever!!! Is there some just plain old english instructions out there?

M. Hossein Amerkashi

unread,
Sep 9, 2011, 9:18:55 AM9/9/11
to appto...@googlegroups.com
hmm. Somehow the link to original posting by Mark Friedman for AI Bridge that I listed above has changed. This is the new link HERE

Tennessee Fox

unread,
Aug 7, 2012, 4:28:25 PM8/7/12
to appto...@googlegroups.com
I have a question.  Ive been trying to transition to eclipse using the bridge, and im having some issues. Ive tried Ryan's, and yours... My question is since they are both using AI as a library, why is the syntax to create a app different?  Ive tried to do some tuts on you tube using the bridge, but they dont work with Ryans, but they work somewhat with yours.   Ive talked to Ryan about this and for those of us who are comfortable with AI and are transitioning we need a format with some AI apps that we can see how the new language works... Ive seen your tutorials for paint pot and such, but do they work with your bridge or Ryans, or both? and I cant find a wiki to say how to use the tutorial.  Please help.  Java is confusing enough.


TIm

M. Hossein Amerkashi

unread,
Aug 9, 2012, 12:50:29 PM8/9/12
to appto...@googlegroups.com
In the code that you sent me, you had error. Here is the updated code. The sections that I update, are commented with //me


package com.fox.monstermash;

import com.google.devtools.simple.runtime.components.Component;
import com.google.devtools.simple.runtime.components.HandlesEventDispatching;
import com.google.devtools.simple.runtime.components.android.Canvas;
import com.google.devtools.simple.runtime.components.android.Form;
import com.google.devtools.simple.runtime.components.android.ImageSprite;
import com.google.devtools.simple.runtime.components.android.Label;
import com.google.devtools.simple.runtime.events.EventDispatcher;


public class MonsterMash1Form extends Form implements HandlesEventDispatching
{

    // Declare global variables here
    Canvas gameCanvas;
    ImageSprite Werewolf;
    int score;
    Label ScoreLbl;

    void $define() {
        // This sets the UI designed in the graphical editor to our Form's UI.

        //me: don't need the following statement
//        setContentView(R.layout.main);

        //me: moved ScoreLbl to top of screen

        score = 0;
        ScoreLbl = new Label(this);
        ScoreLbl.BackgroundColor(COLOR_WHITE);
        ScoreLbl.Text(Integer.toString(score));


        gameCanvas = new Canvas(this);
        gameCanvas.BackgroundColor(COLOR_GREEN);
        gameCanvas.BackgroundImage("screenmain.jpg");
        gameCanvas.Height(600);
        gameCanvas.Width(LENGTH_FILL_PARENT);

        Werewolf = new ImageSprite(gameCanvas);
        Werewolf.Picture("d.jpg");       //for my purpose
        Werewolf.X(100.0d);
        Werewolf.Y(100.0d);

        // This method captures the initialization event of this Form, so we can do stuff when the
        // screen first gets initialized.
        EventDispatcher.registerEventForDelegation(this, "ScreenInitialization", "Initialize");

        //me: added following. You need to register Touched event
        EventDispatcher.registerEventForDelegation(this, "ScreenInitialization", "Touched");


    }

    @Override
    public boolean dispatchEvent(Component component, String id, String eventName, Object[] args) {

        if (component.equals(this) && eventName.equals("Initialize")) {
            screenInitialized();
            return true;
        }

        //me: added following to capture touched event
        else if ( eventName.equals("Touched"))
        {
            if (component.equals(Werewolf))
            {
                doTouched((Float) args[0], (Float) args[1]);
                return true;
            }

            return false;

        }
        return false;
    }

    //me: renamed the Touched method
    //me: you don't really need the 3rd argument
//    public void doTouched(float x, float y, boolean touchedsprite)  {
    public void doTouched(float x, float y)  {

            score = score + 1;
            ScoreLbl.Text(Integer.toString(score));
    }
    private void screenInitialized() {
        // This method is run when the screen is initialized, and reports a valid width/height.
Reply all
Reply to author
Forward
0 new messages