Draw A Marker

Started by Vincent, Sat 16/11/2013 16:17:43

Previous topic - Next topic

Vincent

how can i place a marker over the players head, to mark an interactable location and make it as the marker follow
exactly the player head when he stand on region ?
also, how to make that marker animated anytime he stand on region ?
i am not so sure if it must be an object or a Gui ?!

Ghost

#1
I would make a [separate] character and assign the marker animation as its view. You can then use the FollowCharacter command:

Character.FollowCharacter(Character* chartofollow, optional int dist, optional int eagerness)
"Tells the character to follow CHARTOFOLLOW around, wherever he goes. You could use this command to have a group of main characters who go around together, or for example when the hero has rescued someone from the bad guy, they can follow the hero home."

Since you can stop, change and switch animations for characters easily, all you mention in your post can be done easily. Simpler than a GUI, and much better than an object (which could only be used in ONE room).

Khris

You should actually use a character for the marker. That way, you can use cMarker.FollowCharacter(player, ...); and move it up by using cMarker.z (multiplied by the character's scaling/100 if you're using that).

To find out whether the player walked onto or off a region:
Code: ags
int last_region;

// inside repeatedly_execute_always
  Region *r = Region.GetAtRoomXY(player.x, player.y);
  if (r.ID != last_region) {
    if (r.ID > 0) {
      // player just stepped on region r.ID
      if (last_region == 0) {
        // player wasn't on region before
        cMarker.Transparency = 0; // show marker
        cMarker.LockView(MARKERVIEW); // animate marker
        cMarker.Animate(...);
      }
    }
    else {
      // player stepped off any region
      cMarker.UnlockView();
      cMarker.Transparency = 100;
    }
  }
  last_region = r.ID;

Vincent

Amazing ! :-D Very Happy ! :-D
Thanks Ghost for helping  ;)

Khris,
You Are The Saviour. This is well-known!

Cheers!, Hurrah! :-D

Vincent

#4
Hello Again Guys.. I Feel Sorry Anytime to trouble you :-X
I Tried Out Lately The Khris Method For Regions, It Work Excellently
Also Scaling With The cMarker.z, it Work Amazing..
But..
The Marker follow the player, cMarker.FollowCharacter(player, 0, 0);
But DON'T So Exactly How I Wish For...
Instead..
If I Use cMarker.FollowCharacter(player, FOLLOW_EXACTLY); Then It's Good...
But Can't Scaling The cMarker.z Then ?
Cause he'll FOLLOW_EXACTLY the player.x and player.y :~(

Khris

Instead of Follow_Character / FOLLOW_EXACTLY you can use

Code: ags
  // add to end of repeatedly_execute_always
  cMarker.Room = player.Room;
  cMarker.x = player.x;
  cMarker.y = player.y;


(you don't need cMarker to use the same loop/frame anyway)

Vincent

Best Devotion,

Thanks Khris,

It Work Perfectly now (nod)



SMF spam blocked by CleanTalk