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

2015/6/25

help (invinity scrolling)

1
2
3
Super_Hippo Super_Hippo

2015/6/28

#
Change the 'getX()' in line 20 of the 'worlds' class to 'getY()'.
danpost danpost

2015/6/28

#
Super_Hippo wrote...
Change the 'getX()' in line 20 of the 'worlds' class to 'getY()'.
That was my fault ... sorry.
jaki jaki

2015/6/29

#
ok now it works ty @Super_Hippo but how to go on ? now the character (mario) can move right and left but the object is staying at one place all time we also can write in skype if its easier for u
danpost danpost

2015/6/29

#
jaki wrote...
ok now it works ty @Super_Hippo but how to go on ? now the character (mario) can move right and left but the object is staying at one place all time
Have you added any code to make mario move up or down (in the mario class)? Have you tried adding other objects into the world to see how they move with respect to mario when you manually drag mario off the vertical center and click the Act button?
jaki jaki

2015/6/30

#
I already created the Mario class with the methods right and left . I also added an object ... but Mario just move right or left and the object is standing all time on the same place :( pls help me
danpost danpost

2015/6/30

#
jaki wrote...
I already created the Mario class with the methods right and left . I also added an object ... but Mario just move right or left and the object is standing all time on the same place :( pls help me
So ... no, you do not have any code for up and down (which is necessary if you want mario to move up and down with respect to other objects); and ... no, you have not tried to drag Mario off center and click the Act button (to see if the scrolling actually works correctly).
jaki jaki

2015/6/30

#
wtf dude if i drag mario away and press act he instant teleports somewhere (also with the object )
jaki jaki

2015/6/30

#
wtf dude if i drag mario away and press act he instant teleports somewhere (also with the object ) if you want i can sent you a pic
danpost danpost

2015/6/30

#
jaki wrote...
wtf dude if i drag mario away and press act he instant teleports somewhere (also with the object ) if you want i can sent you a pic
No need for pic. That is what is supposed to happen (and what you asked for to happen). When Mario goes off center, he will move back to the center (vertically) and all other objects should move the same amount (keeping the same positional relationships between each other). Mario will not be jumping way off center as you dragged him; so, what will actually happen is that when Mario moves slightly off center, the repositioning of all objects will make Mario appear to move with respect to everything else and still maintain his position in the vertical center.
danpost danpost

2015/6/30

#
Maybe you really wanted horizontal scrolling -- not vertical (which is what you said you wanted). If that is the case, you need to adjust the scrolling code I gave to work horizontally instead of vertically.
jaki jaki

2015/6/30

#
oh shit ;) you re right my fail sorry i need horizontal scrolling sorry what do i have to change ?
jaki jaki

2015/6/30

#
here is my world class
import greenfoot.*;

public class worlds extends World
{
    private Actor maincharacter;

    public worlds() {
        super(600, 400, 1); 
        maincharacter= new mario();
     addObject(maincharacter,300,200);
        addObject (new object(),200,200);

       
    } 

    public void act (){
        if (maincharacter.getWorld() == this){
            
            int dy = maincharacter.getY()-getHeight()/2; // ausgleciehn
            if (dy!= 0 )  {// nicht in der Mitte 
                for (Object obj : getObjects(null)) {// für alle actors 
                    Actor actor = (Actor)obj; //bezieht object als actor object
                    actor.setLocation(actor.getY(), actor.getX()-dy); 

                }
            }

        }
    }
}
and here the mario class
import greenfoot.*;

public class mario extends Actor
{
    public void act() 
    {
        if (Greenfoot.isKeyDown("up")) {
            setLocation(getX(), getY() - 3);
        }
        if (Greenfoot.isKeyDown("down")) {
            setLocation(getX(), getY() + 3);
        }
        if (Greenfoot.isKeyDown("left")) {
            setLocation(getX() - 3, getY());
        }
        if (Greenfoot.isKeyDown("right")) {
            setLocation(getX() + 3, getY());
        }

    }    

}
Super_Hippo Super_Hippo

2015/6/30

#
Do you understand what each line of code does? If yes, you can easily change it yourself. If not, which part/line of code do you have problems with?
jaki jaki

2015/7/1

#
yeah dudes i did it now it works thanks alot <3 i love you sooo much ;)
jaki jaki

2015/7/1

#
im sooo happpppppy
There are more replies on the next page.
1
2
3