HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Compass heading  (Read 1568 times)

Thazager

  • General Accounts
  • *
  • Posts: 1137
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Compass heading
« on: Jan 19, 13, 08:40:19 PM »

This is for making a compass to use instead of the one across the top of screen. If mouse is scrolled to far, it hides, adjust with turn keys.

__________________________________________________________________
From the basic window tutorial
Make basic window here. This is a base window and will be used in many of my Tutorials. It uses the GUI pics from textures that all engines have. This can be skipped if you have the basic window already from another tutorial.

_________________________________________________________________________
In the DOM, creat a new (client side) class.
    name = TMP_Compass
    archtype = guicontrol
    add a parent to the class, TMP_Window

Code: [Select]
// create main window
shared function Start()
  var win = getCompass()
  if win <> None
    DestroyNode( win )
  .
  win = CreateNodeFromPrototype("TMP_Compass")
  win.build = true
  MiscUtils:centerWindow(win)
  EnableHeroBladeCompass(false)   // remove old
.

// set the compass heading
public function setCompass(heading as Float)
  var compass = getCompassSetting()
  if compass <> None
    pos as Integer = Round(heading) * -1 + 60
    if pos < -320
      pos += 360    // relocate at front of panel
    .
    if compass.position.x <> pos
      compass.position.x = pos
    .
  .
.

//=================================================================================================
function getCompass() as NodeRef of Class TMP_Compass
  return FindGUIControlByName(None, "game.TMP_Compass")
.

function getCompassSetting() as NodeRef of Class GUIControl
  return FindGUIControlByName(None, "game.TMP_Compass.compassPic.slot.compass")
.

_________________________________________________________________________
In new (XML) script TMP_Compass

Code: [Select]
<createControlType inheritFrom='TMP_Window' class='TMP_Compass' type='TMP_Compass' description='' treePath='' name="TMP_Compass">
  <_panel name="compassPic" texture="\GUI\chat_v2.dds">
    <position x="10" y="10"/>
    <size x="230" y="40"/>
    <defaultStatePresentation>
      <position x="440" y="4"/>
      <size x="67" y="65"/>
    </defaultStatePresentation>
    <_panel name="slot">
      <position x="55" y="12"/>
      <size x="120" y="15"/>
      <maximumSize x="2048" y="2048"/>
      <defaultStatePresentation>
        <color a="0"/>
      </defaultStatePresentation>
      <_panel name="compass">
        <size x="380" y="15"/>
        <anchor top="false" left="false"/>
        <defaultStatePresentation>
          <color r="0" g="0" b="0" a="0"/>
        </defaultStatePresentation>
        <hoverStatePresentation>
          <color r="0" g="0" b="0" a="0"/>
        </hoverStatePresentation>
        <_label name="north" text="N" displayfont="JUMBO">
          <size x="12" y="16"/>
          <defaultStatePresentation>
            <color r="1" g="0" b="0"/>
          </defaultStatePresentation>
        </_label>
        <_label name="east" text="E" displayfont="JUMBO">
          <position x="90"/>
          <size x="12" y="16"/>
          <defaultStatePresentation>
            <color r="1" g="0" b="0"/>
          </defaultStatePresentation>
        </_label>
        <_label name="south" text="S" displayfont="JUMBO">
          <position x="180"/>
          <size x="12" y="16"/>
          <defaultStatePresentation>
            <color r="1" g="0" b="0"/>
          </defaultStatePresentation>
        </_label>
        <_label name="west" text="W" displayfont="JUMBO">
          <position x="270"/>
          <size x="12" y="16"/>
          <defaultStatePresentation>
            <color r="1" g="0" b="0"/>
          </defaultStatePresentation>
        </_label>
        <_label name="north2" text="N" displayfont="JUMBO">
          <position x="360"/>
          <size x="12" y="16"/>
          <defaultStatePresentation>
            <color r="1" g="0" b="0"/>
          </defaultStatePresentation>
        </_label>
      </_panel>
    </_panel>
  </_panel>
</createControlType>

_________________________________________________________________________
In (client side) script ACCControllerClassMethods add

In method _HE_ACCC_NavigateLocal() of script

under line
        camrot as Vector3 = GetNodeRotation(cam)

add
Code: [Select]
        TMP_CompassClassMethods:setCompass(camrot.y)

_________________________________________________________________________
In (client side) script E_PlayerAccountClassMethods under the chat window,

Code: [Select]
        TMP_CompassClassMethods:Start()

« Last Edit: Jun 01, 15, 03:02:56 PM by Thazager »
Logged