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

2015/1/11

A few questions for my game,

1
2
Socrates Socrates

2015/1/11

#
Hi guys, I have a few questions that I'm trying to do but I'm stumped. I used Scrolling SuperWorld to get my side scrolling and I can't seem to add an object that doesn't scroll (exempted from the side scrolling aswell as having so collision) . I'm almost having trouble trying to get objects to spawn when the player (actor class) passes a certain point ie. x: 3000, it spawns another actor object (a title). The code I have for this is: public void act(){ spawnTitle(); } public void spawnTitle(){ if (getX() > 300){ getWorld().addObject(igControls, 500, 500); } } Thank you!
danpost danpost

2015/1/11

#
Did you try:
getWorld().addObject(igControls, 500, 500, false);
danpost danpost

2015/1/11

#
Is 'igControls' a field that holds the actor for the title? or is it the name of the class that creates the title object?
Socrates Socrates

2015/1/11

#
igControls is another actor class I have that's just a picture that has the controls, I wanted it to appear on the screen when the player actor goes past a certain x coordinate on the screen
danpost danpost

2015/1/11

#
If it is a class name, then you are trying to add a class into the world with your code. It is not the class you want to add, but an object created from that class. You can create an object by using the 'new igControls()'. Replace 'igControls' in the 'addObject' line with that.
Socrates Socrates

2015/1/11

#
I have : public void spawnTitles() { if (getX() > 400) { getWorld().addObject(new controls(), 500, 500, false); } } ( i renamed the actor to controls ) still doesnt seem to work
Socrates Socrates

2015/1/11

#
and how do I make an object ( in my case I want an overlay on the screen to mimic a tv screen, like youre playing the game off off an atari), un scrolling in my scrolling level
danpost danpost

2015/1/11

#
The 'false' parameter at the end of the 'addObject' parameter list tells the scrolling system that the object being added to the world is not to be scrolled.
still doesn't seem to work
How is it not working? not showing up in the world? and how can you be sure? where are you calling the 'spawnTitles' method from? BTW, please use code tags around your code. Posting code? read this!.
Socrates Socrates

2015/1/11

#
oh sorry I didnt read that, I'll use it in the future. I'm calling this in the actor class for my player 1
danpost danpost

2015/1/11

#
Socrates wrote...
oh sorry I didnt read that, I'll use it in the future. I'm calling this in the actor class for my player 1
Where in the class are you calling it?
Socrates Socrates

2015/1/11

#
I made a method and I put that method in my act class
Socrates Socrates

2015/1/11

#
when I make the unscrolling object false, my actor goes invisible but still moves
danpost danpost

2015/1/11

#
Please post the code to the act method.
Socrates Socrates

2015/1/11

#
    public MyWorld()
    {    
        super(1074, 767, 1, 6000);       
 addMainActor(new Player(), 400, 342, 250, 300); 
        GreenfootImage bg = new GreenfootImage("NEWNEWTutorialLevel.png");
        setScrollingBackground(bg); 
        addObject(new Ground1(), 2223, 658);
        addObject(new Ground2(), 5309, 700);
        addObject(new DiePlatform(), 4600, 756);
        addObject(new TvBorder(), getWidth()/2, getHeight()/2, false);
}
danpost danpost

2015/1/11

#
That was not the act method of you player I class.
There are more replies on the next page.
1
2