Jump to content


Photo

Calling a draw even from another object.


  • Please log in to reply
4 replies to this topic

#1 KreeDz

KreeDz

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 24 April 2012 - 08:04 AM

Hello, so i've been working on a sprint/stamina bar for a while now. I`m kinda facing a problem right now. The draw_ functions can only be used under the draw events which i`m not able to use so on the characters draw event as it's gonna mess up things for me. I don't even want to use it there, as i need the sprint bar "fixed" somewhere on the screen.

So, i was thinking. If i put the draw code under let's say, a stamina bar object. How would i be able to make that object read the code from the character's STEP and Create. As that's where the variable and code are.

If i try the object by itself, it will say that the variables are not created and if i create them under the stamina bar object, they ain't update as the update code is under Step in the char's object.



Thanks to anyone willing to help!

Edited by KreeDz, 24 April 2012 - 08:04 AM.

  • 0

#2 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 383 posts
  • Version:GM:Studio

Posted 24 April 2012 - 08:36 AM

If what you meant with reading code is accessing obj_player's variable while in other object event, then just use obj_player.your_variable.
Hope it helps.
  • 0

#3 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 10099 posts
  • Version:GM8

Posted 24 April 2012 - 02:36 PM

The step event is executed before the Draw event, so referencing the player's variables in the draw event will show use the variables as they have been set by the end of the End Step event.
  • 0

#4 KreeDz

KreeDz

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 24 April 2012 - 04:32 PM

So, it was that easy... char.stamina... thank you very much :).

TheouAgeis. Sorry, didn't fully understand your point but, all i needed was to read an dynamic variable from the player object to use it in another object.
  • 0

#5 Fihrilkamal

Fihrilkamal

    GMC Member

  • GMC Member
  • 383 posts
  • Version:GM:Studio

Posted 24 April 2012 - 05:18 PM

So, it was that easy... char.stamina... thank you very much :).

TheouAgeis. Sorry, didn't fully understand your point but, all i needed was to read an dynamic variable from the player object to use it in another object.


Yes it is, and you're welcome.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users