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

2011/7/14

How to make a delay

1
2
3
davmac davmac

2011/7/15

#
kiarocks, I have your COKE THING scenario code; but I don't understand what you want to pause nor when.
kiarocks kiarocks

2011/7/15

#
i want it before the addObject part on both actors.
danpost danpost

2011/7/15

#
If the object(s) is(are) not yet added, then putting any code in the 'act' method is useless. You cannot really 'pause' an actor that is not present, but you can hold off on 'addObject'. Is it just a time thing, where you want to wait a second or more before adding the object(s), or is it that you want something else to happen first? and if so, what? Maybe -- would it be an idea to go ahead and 'addObject' the object(s) with a clear (transparent) image until such time as to make them visible by changing the image of the object(s)? Then, you could use the code I suggested previously to ensure no action is taken until object(s) are visible (by changing 'isActive' to 'true' when making the object(s) visible; create the object(s) with 'isActive = false').
kiarocks kiarocks

2011/7/15

#
no, i want to delay it so i dont end up with 100000000 actors.
kiarocks kiarocks

2011/7/15

#
and they are already there, if that helps.
danpost danpost

2011/7/15

#
What is causing the actors to be created?
danpost danpost

2011/7/15

#
OK, I looked at your COKE THING scenario. You are starting with a single object that on each 'act' creates an instance of a different object. Then, on each 'act' for the new different object, it created another instance of the first object. Therefore, here is a table of object counts at each 'act' ACT# Bottles Mentos 0 1 0 1 1 1 2 2 2 3 4 4 4 8 8 5 16 16 6 32 32 7 64 64 8 128 128 9 256 256 10 512 512 11 1024 1024 12 2048 2048 Anyone can see how quickly you will run out of memory at this rate! How do you intend to control the population explosion of your actors? They either need to stop producing objects or objects need to be removed as quickly as they are produced or better. There has to be some control!!! What is it that your scenario is actually trying (going) to do? By the way, slowing down the production will not solve the problem. You will still eventually run out of memory.
kiarocks kiarocks

2011/7/15

#
im just playing for a while and i will delete at about 2048 on both
davmac davmac

2011/7/16

#
GameCode posted some code to pause an actor. Just replace the calls to Method1() and Method2() in his sample code with what you currently have in act(). Then set pause=100 (or whatever) just after that, to pause again.
kiarocks kiarocks

2011/7/16

#
how do you see how many objects are in the world?
danpost danpost

2011/7/16

#
The easiest way is to 1) Right-click on the world 2) Select 'Inherited from World' 3) Select 'int numberOfObjects()' and an info-box pops up showing you the value returned from the method.
MissingUsername MissingUsername

2011/7/16

#
I kinda have the same problem. I have one of my actors create duplicates of another actor upon interaction. I only want one duplicate to be created but it creates several (20-30) as soon as it comes into contact. Would there be a instruction to tell the program to make only 1 copy or maybe pause it from adding object for a certain amount of seconds after the first one has been created? Here's the code I used: /** * This method duplicates the object when caught. */ public void duplicate() { if (canSee (Crab.class)) { getWorld().addObject (new Crab(), 0, 0); } }
kiarocks kiarocks

2011/7/16

#
danpost, how do you do that for one object only?
kiarocks kiarocks

2011/7/16

#
nvm last post
danpost danpost

2011/7/16

#
To get a count of a specific class of objects: 1) Right-click on the world 2) Select 'Inherited from World' 3) Select 'List getObjects(class)' 4) Enter the name of the class (exactly as you named the class; if 'mentos', key in 'mentos.class'; if 'Mentos', key in 'Mentos.class') and press ENTER An info-box show the return of an ArrayList should pop up. Select 'Inspect' on the 'Method return' dialog-box and the second item will be the number of the type object in the world at the moment.
There are more replies on the next page.
1
2
3