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

2013/5/15

counter probz

mezboycalday mezboycalday

2013/5/15

#
sup homies, i cant do a counter that changes when i get a person, help meeeeeee ta kidz
Gevater_Tod4711 Gevater_Tod4711

2013/5/15

#
What exactly should the counter do and what is your problem doing this?
mezboycalday mezboycalday

2013/5/15

#
it should count when my actor goes over another actor and picks it up ta lid
Gevater_Tod4711 Gevater_Tod4711

2013/5/15

#
So if your actor tuches another actor you want your counter to start counting?
mezboycalday mezboycalday

2013/5/15

#
every time i pick up an actor the counter should add 1
Gevater_Tod4711 Gevater_Tod4711

2013/5/15

#
Oh ok. So when your actor intersects the other object you have to pick it up:
Actor pickedUpObject = getOneIntersectingObject(Actor.class);//or any other class;
if (pickedUpObject != null) {
    getWorld().removeObject(pickedUpObject);
    //the code for counting up the number of picked up objects;
}
Then you have to add one to the counter. There are serval ways for doing that. That depends on how your code looks like at the moment: Have you got only one counter object in the world? Have you got a reference to the object in your world class?
You need to login to post a reply.