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

2012/9/17

Multiple funtions at one time

1
2
3
danpost danpost

2012/9/17

#
Try commenting out the acts of all the classes except the lighter class (which means you do not comment out the act of AnimatedActor either) and see if it works then. If so, un-comment one act at a time to find out which one may be causing the problem. If you are able to narrow it down to one act, try un-commenting each part of it individually to see where in the act you are creating the problem. In the event that the problem persists after commenting out all the acts, try commenting out each part of the lighter act (I would start with the last 'if' first).
jhadad jhadad

2012/9/17

#
Thanks, I will try that. But just from browsing around the scenarios im seeing this in a lot of things, like gladiatorRecode by nic, you can move around at all times but you can only aim when you arent pressing any of the move buttons
danpost danpost

2012/9/17

#
Yeah, I know. It is in the way they programmed it. A lot of times you will see something like 'if.. else if.. else if..' to check keystrokes. In doing so, only the first key caught will be acted on. There are different ways to program that where you will not be limited like so.
jhadad jhadad

2012/9/17

#
Ok well i have commented out all of the acts and everything inside of the lighter actor except for
      if(Greenfoot.mouseMoved(null)) { 
            MouseInfo mouse = Greenfoot.getMouseInfo(); 
            setLocation(mouse.getX(), mouse.getY()); 
        } 
and obiously the super.act(); because its an animated actor but it still is not working
danpost danpost

2012/9/17

#
In the lighter class, you need to uncomment the other parts of the act, and you need to comment out the above code. Then, start uncommenting things until it breaks again. SORRY, do not comment out the above, comment out the last 'if' block: if (Greenfoot.mouseClicked(this)) { ... }.
jhadad jhadad

2012/9/17

#
But then it wont follow the mouse and I wont know if it stops moving or not.
danpost danpost

2012/9/17

#
See my edit above.
jhadad jhadad

2012/9/17

#
I already had that commented out.
danpost danpost

2012/9/17

#
So, you should have 'super.act()' and 'if (Greenfoot.mouseMoved(null)) {...}' and 'if (Greenfoot.isKeyDown("v"))' as the only things that should run right now. And it still freezes?
jhadad jhadad

2012/9/17

#
I dont even have the Greenfoot.isKeyDown("v"), the lighter just follows the mouse and when I press any button, it stops moving until i release.
danpost danpost

2012/9/17

#
It does compile, though. Can you unload the scenario with source, so I can download it to see what you have? I can let you know when I have it so you can delete it off the site if you want.
jhadad jhadad

2012/9/17

#
Yes, it is very basic right now with the pictures but I'm just trying to get the code done. I will put it up right now though
jhadad jhadad

2012/9/17

#
How do you upload a scenario to the site?
danpost danpost

2012/9/17

#
Click on the 'Share' button at the top-right corner of the Greenfoot window (just under the 'minimize/maximize/close' buttons). Make sure 'Publish' is selected at the top of the new window and make sure you check the checkbox for 'Publish source code' before you click the 'Share' button on this window.
danpost danpost

2012/9/17

#
OK, I have it. You can log in, select the scenario and click on 'Delete scenario' somewhere near the big green 'Open in Greenfoot' button near the top right of the scenario window to remove it.
There are more replies on the next page.
1
2
3