This site requires JavaScript, please enable it in your browser!
Greenfoot back
DonaldDuck
DonaldDuck wrote ...

2012/1/5

Greenfoot Mobile App?

7
8
9
10
11
12
13
Upupzealot Upupzealot

2012/11/17

#
I'v updated the demo scenario, the project included now should have no problem.(It should works well with Eclipse and AIDE both) If you still have problem with "@Override" things, see above.
DonaldDuck DonaldDuck

2012/11/17

#
@tylers I feel you :) I started this thread and haven't really even replied since! The updates are pretty interesting though.
Upupzealot Upupzealot

2012/11/17

#
Any question is welcomed. BTW, you may "like" that demo scenario, so you can notic as soon as I updated somrthing.
erdelf erdelf

2012/11/17

#
I tried to find it out by myself, but it seems I dont understand it. How do you recognize which part of the screen is pressed?
Upupzealot Upupzealot

2012/11/17

#
What do you mean? You mean in keyboardmod? Since code for Greenfoot4Android is open, you may get related codes in the class TouchManager.
erdelf erdelf

2012/11/17

#
yes, I tried it with the Touchmanager Class but I dont get it.
Upupzealot Upupzealot

2012/11/17

#
I write the class TouchManager to manage touch events which are got from the screen. Also I did some transform to the coordinate to let it fit with the current world not your screen
-nic- -nic-

2012/11/17

#
the update to Upupzealot's runner game has fixed the @override issue
Upupzealot Upupzealot

2012/11/17

#
Actually I didn't change any thing. I just import my code into Eclipse and update it again. It seems that my Eclipse fixed that automatically. If anyone meet the same problem again, try 1.use Eclipse for Java Developer 2.try this: enter Eclipse -> right click on your project -> click Resource -> find "Text file encoding" in right side -> pick “Other” -> choose "UTF-8" or other what you think is OK
-nic- -nic-

2012/11/17

#
thats strange i just wiped and then reloaded thee code
Upupzealot Upupzealot

2012/11/17

#
@erdelf I missed your last reply. The most important method is public void onTouch(View v, MotionEvent event) fot the touchmanger is related to a SurfaceView of the App, it will get all touch event. Things about motion and coordinate is included is the MotionEvent. What I have done is get the information from the mothion event and put it into the MouseInfo or KeyInfo objects.
erdelf erdelf

2012/11/17

#
thx, for the answer. A question: Where can I set the name of the app? and could you list a few reasons why the app can quit right at the beginning?
groengeel groengeel

2012/11/17

#
You wanted a question, well you got one: Why doesn't the image show:
package LandThePlane;

import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
import java.util.ArrayList;

/**
 * An AntiAirGuns main goal is to kill the plane.
 * It tries to do this by following the planes and if the gun is loaded shoots a bullet.
 * The loadtime is defined in the shootInterval variable.
 * Guns get inactive when a message is displayed, this means either the player landed or died.
 * 
 * @author Kevin van Oosterhout
 * @version 1.0
 */
public class AntiAirGun extends Actor
{
    private List<Plane> planes = new ArrayList();
    private int counter = 0;
    private int shootInterval;
    private boolean active = true;
    
    /**
     * initiate the gun.
     */
    public AntiAirGun(int shootInterval) {
        this.shootInterval = shootInterval;
        setImage("AntiAirGun.png");
    }
    /**
     * Use the method findPlane to follow the plane and kill it.
     */
    public void act() 
    {
        if(active == true) {
            findPlane();
        }
    }    
    
    /**
     * First we read all planes in a List called planes. We follow one, this is not random,
     * but we don't really care which one we follow, in our game, we'll mostly have just one plane,
     * and if we have more, we're comfortable with the gun just following the last one in the List.
     * Last, we call the shoot method.
     */
    private void findPlane() {
        planes = getWorld().getObjects(Plane.class);
        for (int i=0; i < planes.size(); i++) {
            Plane plane = planes.get(i);
            int px = plane.getX();
            int py = plane.getY();
            turnTowards(px,py);
            shoot(px,py);
        }
    }
    
    /**
     * We need to shoot the plane in order to kill it. 
     * First we check wether the Gun is loaded, this is the case when the counter is 
     * equal to or higher than the shootInterval.
     * If so, we create a new Bullet and give it the correct rotation/heading, 
     * and place it in the world where the position of this object is. We set the counter to 0.
     * 
     * If not, we add up 1 to our counter.
     */
    private void shoot(int x, int y) {
        if (counter >= shootInterval) {
            getWorld().addObject(new Bullet(getRotation()),getX(), getY());
            counter = 0;
        } else {
            counter++;
        }
    }
    
    /**
     * When a message is displayed, it will set the gun to inactive, we do this here.
     */
    public void setInactive() {
        active = false;
    }
}
-nic- -nic-

2012/11/17

#
the app doesent update itsself it just stays like it started
Upupzealot Upupzealot

2012/11/17

#
@erdelf To change the name of the app: Enter projectfolder/res/string.xml then change"Runner" to whatever you want. Also if you want to change the icon of the app: Enter projectfolder/res and change every "icon.png" to other pics also named "icon.png" with the same size. The only reason for quit is: Your code still has Exceptions. Maybe it works well in Greenfoot, but after all, Greenfoot4Android is not as strong as Greenfoot.
There are more replies on the next page.
7
8
9
10
11
12
13