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

2021/6/10

Array images

EndlessTimes EndlessTimes

2021/6/10

#
Is it possible to use an array of say 5 images and have 4 of them be useful in some way but the last 1 to end the game and if so how would that be done?
Gbasire Gbasire

2021/6/10

#
I don't really understand, you can just put an array of 5 images and only use 4
EndlessTimes EndlessTimes

2021/6/10

#
what I mean is that if I used an array of 5 images could i single one out to do something differant than the other 4
Gbasire Gbasire

2021/6/10

#
What do you mean by something different ? do you have an example ?
EndlessTimes EndlessTimes

2021/6/10

#
Ok so if I used an array of five images and I have the first image to the fourth of the images set so that when touching another actor like a catcher it will make the counter go up by one but if the fifth image is generated and the catcher touches it the counter would go down. i'm wondering if i would be able to single out the fifth image to be harmful to the catcher
EndlessTimes EndlessTimes

2021/6/10

#
I'm new to coding with Greenfoot so i'm unsure how it would work
Gbasire Gbasire

2021/6/10

#
you can check if the image is a number under 5 to make it change, and if it's not under 5 you don't make it change
danpost danpost

2021/6/10

#
You could do something like this (where the class of falling objects is called Falling and its static image array is called imgSet):
Falling actor = getOneIntersectingObject(Falling.class);
if (actor != null)
{
    if (actor.getImage() == actor.imgSet[4]) damage(); else score();
    getWorld().removeObject(actor);
}
You need to login to post a reply.