Game Development Reference
In-Depth Information
the body is dynamic, it will “feel” the force at that point even if the point isn't near the
shape or sprite—consider the joint's force acting more like magnetism than someone actu-
ally grabbing and pulling the object.
Testing the Springboard for the First Time
Naturally, you'll need to place an instance of the Spring.ccb onto Level1.ccb . Place it near
the player's starting point so that you can immediately see it in the game. You should
move the spring instance into the chains & ropes & springs node to ensure the spring's
draw order is the same as the draw order of the chains and ropes.
You should place the spring so that the base seems to be glued onto a surface of a border
sprite. No need to be perfect, though.
Publish, build, and run the project. You should find that the spring is pulled out and away
from the shaft by an invisible spring. And this happens instantly when the level starts.
If the spring doesn't come out of the shaft easily or does not come out at all, verify that
the shaft and bolt collision shapes don't touch or overlap, and that they are both almost
parallel to each other. Refer to Figure 9-20 for a suitable example.
Blocking the Spring's Movement
Let's tackle the first problem: stopping the spring so that it won't leave the shaft. The
springstopper will get that job.
Open Spring.ccb , and select the springstopper node. On the Item Physics tab, enter
springstopper in the Categories field and enter spring in the Masks field.
Caution Be sure to enter springstopper , not springboard, in Categories and
Masks . For some reason, I kept mixing the two up. If the collisions in this sec-
tion won't work, be sure to double-check the springstopper label.
You also need to edit the stopper's collision shape. The main problem right now is that it's
only about half as wide as it ought to be. Drag the two leftmost points to the left and the
two rightmost points to the right so that the collision shape spans the full width of the
springboard base. The height of the springstopper's collision shape doesn't matter, but its
Search WWH ::




Custom Search