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

2012/11/17

New Greenfoot4Android discussion

1
2
3
4
5
Upupzealot Upupzealot

2012/11/18

#
Good night you two. @groengeel Just hope I didn't figure that out first then.
Upupzealot Upupzealot

2012/11/18

#
@erdelf I'v checked your source code. The problem is you renamed the start folder to src. Do not rename the start folder, any change to this folder or MainActivity class would cause unexpected problem, the only thing to do there is setWorld(). If you want to change the name of your App, just make change in string.xml as I said is enough. Then the name of your pics seems didn't match with your code, you can figure that out in debug mode as I has updated. So just download the newest code from the demo scenario(dropbox hasn't updated yet), do not change the start package, turn on the debug mode, and thing would be much easier. After all, it seems that you are using many pics in the scenario, I'm not sure if Greenfoot4Android could manage so many pics. That means it's possible that your scenario could be a bit slow.
erdelf erdelf

2012/11/18

#
thx for looking over it. In 2 hours I am at my pc and I can try it
groengeel groengeel

2012/11/18

#
It seems to work quite well actually:
    /**
     * Check whether this object intersects with another given object.
     * 
     * @return True if the object's intersect, false otherwise.
     */
    protected boolean intersects(Actor actor){
        int ax = getX() - getImage().getWidth()/2;
        int ay = getY() - getImage().getHeight()/2;
        List<String> ac = new ArrayList();
        for(int ix=0; ix<getImage().getWidth(); ix++) {
            int dx = ax+ix;
            for(int iy=0; iy<getImage().getHeight(); iy++) {
                int dy = ay+iy;
		if (actor.isContain(dx,dy)) {
                	return true;
		}
            }
        }
      return false;
    }
The above code shows up wrong! :( Click on "view plain" to see the correct code. Upupzealot: i'll mail you the code.
Upupzealot Upupzealot

2012/11/18

#
it still don't work rotation...
Upupzealot Upupzealot

2012/11/18

#
BTW, how do you feel with the update. I think it makes things much easier since exception could be caught now.
groengeel groengeel

2012/11/18

#
Did you test it? I believe isContain takes care of that:
    boolean isContain(float px, float py){
        float distance = distanceTo(px, py);
        double degrees = degreesTo(px, py);
        
        float dx = distance * (float)Math.cos(Math.toRadians(degrees - (double)rotation));
        float dy = distance * (float)Math.sin(Math.toRadians(degrees - (double)rotation));
        
        RectF rect = new RectF(-getWidth() / 2, -getHeight() / 2, getWidth() / 2, getHeight() / 2);
        return rect.contains(dx, dy);
    }
	boolean isContain(PointF point){
		return isContain(point.x, point.y);
	}
My code just draws a straight up box around the other object (to explain it simple) and get's all the coordinates in it. For my plane scenario it works, as far as I can see now, quite good.
groengeel groengeel

2012/11/18

#
After a few acts with nothing happening the game crashes, am I the only one experiencing that?
Upupzealot Upupzealot

2012/11/18

#
turn on the debug mod then
erdelf erdelf

2012/11/18

#
how can I turn the debug mode on?
-nic- -nic-

2012/11/18

#
just run in debug mode
-nic- -nic-

2012/11/18

#
can I use import java.util.List;
erdelf erdelf

2012/11/18

#
how?
-nic- -nic-

2012/11/18

#
next to the run button at the top there is a little but press that insted
erdelf erdelf

2012/11/18

#
it crashes on start
There are more replies on the next page.
1
2
3
4
5