Game Development Reference
In-Depth Information
You will notice that the cannon rotates freely, while what we want to do is clamp it so that
it only rotates in a certain area. Go back to the event sheet and select the
Every Tick
event. Press the
C
key to add another condition and add a
Compare two values
condition,
as shown in the following screenshot:
To ensure that the cannon only rotates in a set area, we have to make the range of the
mouse greater than the position of the cannon. To do this, make the position greater than
the X position of the cannon and less than the Y position of the cannon. Set the
mouse.X
value to be of
≥ Greater or equal
in the
Comparison
field, as shown in the following
screenshot: