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

2017/6/20

Help with Jumping in my game

1
2
TheAwesomePuppy404 TheAwesomePuppy404

2017/6/22

#
danpost wrote...
TheAwesomePuppy404 wrote...
I also want have the dog be able to move forward and backward while jumping.
As you have already separated vertical movement from the horizontal movement, this is taken care of. You could rename the 'move' method to 'moveHorizontally' and the 'jump' method to 'moveVertically' to make the names more appropriate. You are asking for a lot here without much to start with. I have started a tutorial on jumping, but have only the basics. I will add what I have to my tutorial site and provide a link once it is up.
Is it up yet?
TheAwesomePuppy404 TheAwesomePuppy404

2017/6/22

#
Oh i found it!
TheAwesomePuppy404 TheAwesomePuppy404

2017/6/22

#
it says it would be inadequate.
danpost danpost

2017/6/22

#
Use the following format to declare (or create) a variable: varType varName; The variable type, or 'varType' can be any primitive type (int, double, boolean, etc) or any Object type (World, Actor, String, etc). The variable name, or 'varName' can be anything beginning with an alpha character or the underscore symbol as long as it is not a java keyword. Generally, by convention, variable names will begin with a lowercase letter and the underscore is hardly ever used. Constant values, however, are usually in all caps. Where a variable is declared determines its scope (how long the variable exists). If declared inside a method, it will only last as long as the method is executing. As a non-static field inside a class (declared outside any methods), a field will be created each time an object is created from that class (created for that created object) and exists as long as the object created exists. As a static field (declared outside any methods), it is created when the project is compiled and exists until the next recompiling of the project (or the project is closed). Static fields are also called class fields because they belong to the class itself; where non-static fields are called instance fields because they belong to the objects created from the class (each object gets one and retains its own value for each one). A variable declared inside a method (a local variable) is usually assigned a value immediately, while fields declared outside any methods may or may not be immediately assigned one. Fields can be given access modifiers (private, public, protected) while local variables cannot. Any variable can be made a constant by adding the 'final' modifier.
TheAwesomePuppy404 wrote...
how you create any old variable (for example the value of x)?
If x is to hold an 'int' value, then:
int x;
The greenfoot compiler may require that you assign a value to it immediately if declared inside a method:
int x = 0;
saying that it may not have been initialized.
danpost danpost

2017/6/22

#
TheAwesomePuppy404 wrote...
it says it would be inadequate.
Read on!
TheAwesomePuppy404 TheAwesomePuppy404

2017/6/22

#
what is an instance field
danpost danpost

2017/6/22

#
TheAwesomePuppy404 wrote...
what is an instance field
A field belonging to an instance created from a class. When you right click on an actor in the world while the scenario is not running and select the 'Inspect...' option, you will see several fields that the actor has (x, y, world, rotation, and image). Each actor (or instance of the Actor class) has these fields.
TheAwesomePuppy404 TheAwesomePuppy404

2017/6/22

#
where is it
danpost danpost

2017/6/22

#
You may want to review the lesson on Classes and Objects in the java tutorials.
danpost danpost

2017/6/22

#
For those interested, the summarized jumping tutorial is located here.
You need to login to post a reply.
1
2