This site requires JavaScript, please enable it in your browser!
Greenfoot back
Back to discussions
USER_NAME
USER_NAME wrote ...

2017/4/21

How to add counter, I have imported class counter (New to greenfoot)

USER_NAME USER_NAME

2017/4/21

#
Hi, Can you tell me how to add the code for the counter or create an actor that adds 1 every time one actor touches the other actor. The scoreboard needs to display the value reached. Thank you, USER_NAME
danpost danpost

2017/4/21

#
USER_NAME wrote...
how to add the code for the counter or create an actor that adds 1 every time one actor touches the other actor. The scoreboard needs to display the value reached.
Please stick to one thing at a time -- like getting a working counter to begin with. The JOC videos (#16) explains how to implement the counter.
USER_NAME USER_NAME

2017/4/26

#
Hello Danpost, nice to meet you. I just got finished with a game of chess, I am back now. I am trying to get the counter working using the imported counter.My game consists of a mouse eating cheese,the cheese moves around as you chase it, then the mouse will eat said cheese.I need the counter to add one point everytime it eats some cheese. I will check out the JOC vids. Thanks, I am off to play some SuDoku Puzzles now.
ChessMaster123 ChessMaster123

2017/4/26

#
Why hello fellow chess players, I am also struggling with making a counter work and I would really appreciate some help. Thanks!
USER_NAME USER_NAME

2017/4/26

#
The video posted onto youtube (Joy of code #16) is very quiet and i cannot hear the man speaking. Oh, Hi fellow chess player. Thanks, USER_NAME
ChessMaster123 ChessMaster123

2017/4/26

#
I have had similar issues to you Mr. USER_NAME, The JOC videos are very quiet and I think my hearing aid is a bit faulty.
danpost danpost

2017/4/26

#
USER_NAME wrote...
Hello Danpost, nice to meet you. I just got finished with a game of chess, ... I am off to play some SuDoku Puzzles now.
Hi fellow chess players: Billards, chess and Sudoku are some of my favorites. Fastest Sudoku with my Sudoku scenario here on the site is 2m 3s -- avg between 5-6m. I also have a couple of Chess scenarios here on the site (one, more towards learning the game, the other, more for playing).
I am trying to get the counter working using the imported counter.My game consists of a mouse eating cheese,the cheese moves around as you chase it, then the mouse will eat said cheese.I need the counter to add one point everytime it eats some cheese.
Something like this should work:
if (isTouching(Cheese.class))
{
    removeTouching(Cheese.class);
    ((MyWorld)getWorld()).getCounter().add(1);
}
If you still are having issues, start by posting your World subclass codes.
USER_NAME USER_NAME

2017/4/27

#
Hi, Thanks for the recommendation on the games, which I will check out,I have added the lines you have supplied into my subclass, and it works.I just need to check if it meets requirements. Many thanks, User_name
ChessMaster123 ChessMaster123

2017/4/27

#
Wow! Thanks guys! It really worked you really saved me! Maybe we could play chess some time.
USER_NAME USER_NAME

2017/5/18

#
Good morrow, danposts, is thither a more simplified variation of this counter that thee speaketh of. grant you mercy, USER_NAME
USER_NAME USER_NAME

2017/5/18

#
bump
ChessMaster123 ChessMaster123

2017/5/18

#
How goeth 't mine friends, Any advice would most forsooth be'est greatly appreciated. I has't hath found that this counter can be'est a little confusing and I wonder if 't be true thither may be'est an alternative. I behold forward to hearing from thee about this matter, ChessMaster123.
danpost danpost

2017/5/18

#
USER_NAME wrote...
is thither a more simplified variation of this counter that thee speaketh of.
You could check out my Value Display Tutorial which explain all about that.
USER_NAME USER_NAME

2017/5/23

#
thanks much appreciated.
You need to login to post a reply.