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

2020/6/14

Trying to spawn actors at different times

1
2
3
4
kirajim kirajim

2020/6/17

#
With the pipes and bird they actually look fine i can make it smaller but would that help them from not disappearing?
danpost danpost

2020/6/17

#
kirajim wrote...
With the pipes and bird they actually look fine i can make it smaller but would that help them from not disappearing?
The "round" image of the coin may be surrounded by a lot of complete rows and columns of transparent pixels, making the image frame much larger than needed for the coin. Try this: remove the isTouching coin part from the bird class and then, in the Coin class, try using getObjectsInRange for bird objects.
kirajim kirajim

2020/6/17

#
ok sure ill try that but is there a code for getObjectsInRange
danpost danpost

2020/6/17

#
kirajim wrote...
ok sure ill try that but is there a code for getObjectsInRange
It is an Actor class method -- see here.
kirajim kirajim

2020/6/17

#
i took this code out from the bird class
 if (getOneIntersectingObject(Coin.class)!= null) {
            removeTouching(Coin.class);
and then i added this code which is giving me an error
kirajim kirajim

2020/6/17

#
  if (getObjectsInRange(FlappyBird.class)!= null) {
            removeTouching(Coin.class);
   
    }  
danpost danpost

2020/6/17

#
The link shows you what is needed. It needs an int value for the range as well as the class. You may need to mess around with the int value to make it work well with the coin image.
kirajim kirajim

2020/6/17

#
getWorld().removeObjects(getObjectsInRange(200, Coin.class));
is this what you mean
kirajim kirajim

2020/6/17

#
Thats in the coin class By the way
danpost danpost

2020/6/17

#
kirajim wrote...
getWorld().removeObjects(getObjectsInRange(200, Coin.class));
is this what you mean
The int value will need to be reduces to fit. Also, the getObjectsInRange method always returns a List object -- it is never null. So, you should not use "!= null", but ".size() > 0".
danpost danpost

2020/6/17

#
kirajim wrote...
Thats in the coin class By the way
Yes. So the method should be looking for birds in range -- not coins.
kirajim kirajim

2020/6/17

#
I am really sorry but im super new to coding so i have no idea whats happening so i put this code
 if (getObjectsInRange(FlappyBird.class).size() > 0 ) {
          getWorld().removeObjects(getObjectsInRange(200, Coin.class));
  
  }
but its showing me an error under "getObjectsInRange" i dont know what i should change to fix it
danpost danpost

2020/6/17

#
kirajim wrote...
I am really sorry but im super new to coding so i have no idea whats happening so i put this code << Code Omitted >> but its showing me an error under "getObjectsInRange" i dont know what i should change to fix it
if (getObjectsInRange(50, FlappyBird.class).size() > 0)
{
    getWorld().removeObject(this);
}
kirajim kirajim

2020/6/17

#
Ok the code works thanks. But I kept making the number smaller and the coins only appear when the bird is out of the screen is there a chance something else is wrong
kirajim kirajim

2020/6/17

#
wait never mind it worked thank you soooo much you are a life saver
There are more replies on the next page.
1
2
3
4