The reticule symbol, located in the crosshair layer of Scene 1 of HUDKit.fla, is the container for the firing reticule. reticule contains four symbols, left, right, bottom, and top, each in its own layer. Having each piece of the reticule in its own symbol allows for individual manipulation. The reticule responds to PlayerFire events fired by the simulation whenever the user player fires his weapon. As the player fires a weapon, the reticule will expand dynamically. When the player stops firing, the reticule will return to its original position.
Figure 8: reticule symbol
The reticule update code is divided into two parts, FxHUDView::UpdateEvents() and FxHUDView::OnEvent() methods. The ReticuleHeat and the ReticuleFiringOffset are incremented and set, respectively, in FxHUDEvent when a PlayerFire Event is caught.
// If the player is firing his/her weapon, update the reticule's heat. // The reticule elements are updated in FxHUDView::UpdateEvents() based on // the ReticleHeat and the ReticleFiringOffset. case FxHUDEvent::EVT_PlayerFire: { if (ReticleHeat < 8) ReticleHeat += 2.5f; ReticleFiringOffset = 2; }
FxHUDView::UpdateEvents() uses these two variables to shift the top, bottom, left, and right MovieClips. For each MovieClip, we use SetDisplayInfo() to shift the X or the Y coordinate of the MovieClip. The first number in the equation, 6 or -6, is the starting X or Y offset from the 0, 0 coordinate. Notice that single instance of GFx::Value::DisplayInfo is reused for each SetDisplayInfo() call. However, to ensure that no DisplayInfo is accidently reused, DisplayInfo.Clear() is called after each GFx::Value::SetDisplayInfo() call. This method clears all previously defined display properties for a DisplayInfo instance.
// Shift the XY-coordinates of the reticule elements based on the firing duration and rate of fire. if (ReticleHeat > 0 || ReticleFiringOffset > 0){ if (ReticleHeat > 1.0f) ReticleHeat -= .02f; ReticleFiringOffset -= .02f; if (ReticleFiringOffset < 0) ReticleFiringOffset = 0; info.SetY((-6) - (ReticleFiringOffset + ReticleHeat)); ReticuleMC_Top.SetDisplayInfo(info); info.Clear(); info.SetX((6) + (ReticleFiringOffset + ReticleHeat)); ReticuleMC_Right.SetDisplayInfo(info); info.Clear(); info.SetX((-6) - (ReticleFiringOffset + ReticleHeat)); ReticuleMC_Left.SetDisplayInfo(info); info.Clear(); info.SetY((6) + (ReticleFiringOffset + ReticleHeat)); ReticuleMC_Bottom.SetDisplayInfo(info); info.Clear(); }
For this demo, a simple dynamic reticule equation was chosen for simplicity’s sake, but this code can easily be modified to create more dynamic and creative reticule behavior.