Be a Supporter!

HUD Question

  • 356 Views
  • 11 Replies
New Topic Respond to this Topic
daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
HUD Question 2009-12-12 01:58:02 Reply

What my problem is I have a score but I need it to follow the player so it has to be a separate movie clip
but won't affect anything outside of the movie clip (or vice versa) is there anyway to fix this?


My KKK name is Imperial Warrior

daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to HUD Question 2009-12-12 12:39:25 Reply

BUMP


My KKK name is Imperial Warrior

Johnny
Johnny
  • Member since: Apr. 17, 2004
  • Offline.
Forum Stats
Member
Level 24
Blank Slate
Response to HUD Question 2009-12-12 12:58:33 Reply

We need a more detailed explanation. Draw us a diagram of what you're looking to do, and post your current code.


Perpetually looking for time to return to the arts.

BBS Signature
daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to HUD Question 2009-12-12 13:44:00 Reply

Can code inside a movie clip affect things outside of it

I have a variable and when you touch the object the variable goes up by whatever this works but when I convert the Dynamic Text Box into a movie clip so a code can be applied to it that makes it's x the players x the code that increases the number or says what the number is doesn't work

"Coin Code"

onClipEvent (enterFrame) {
if (this.hitTest(_root.player)) {
	_root.score += 1;
unloadMovie(this)
}
}

My KKK name is Imperial Warrior

A-star
A-star
  • Member since: Dec. 16, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to HUD Question 2009-12-12 13:50:36 Reply

Make your game's vcam visible, and place the HUD items on that. Just make the square's alpha 0.


~1.1

daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to HUD Question 2009-12-12 13:52:05 Reply

At 12/12/09 01:50 PM, A-star wrote: Make your game's vcam visible, and place the HUD items on that. Just make the square's alpha 0.

I did that first off but it's not that its that as soon as the Text box is in a mc it no longer works


My KKK name is Imperial Warrior

andy70707
andy70707
  • Member since: Sep. 30, 2007
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to HUD Question 2009-12-12 14:05:33 Reply

well give the mc an instance name and use _root.movieclipinstancename.textbox


My websites: MayesMods | FireStorm | I'm also on almost every other website in existence, mostly under the username: andy70707 (youtube: brainiac777, eBay: 10andy70707).

BBS Signature
daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to HUD Question 2009-12-12 14:20:31 Reply

Can you elaborate on what I'm supposed to do with this I have a intermediate knowledge of action script
(probably can't tell from my terrible example "Lone Inavader") but I'm not sure exactly what to do with this.


My KKK name is Imperial Warrior

Johnny
Johnny
  • Member since: Apr. 17, 2004
  • Offline.
Forum Stats
Member
Level 24
Blank Slate
Response to HUD Question 2009-12-12 14:27:30 Reply

I think your entire problem is scope, and how movieclips communicate with one another.

A movieClip needs an "address" of the movieClip it needs to talk too, and can only do so one step at a time.

For example, if you have 2x movieClip on the main stage (mc1 and mc2) mc1 could communicate with mc2 through the stage like this:

mc1_.x = _root.mc2_.x; //_root is 1 step away from each.

If you had a 3rd mc (mc3 INSIDE mc2) you could access that from mc1 like this;

mc1._x = _root.mc2.mc3._x;

or from the _root by doing;

variableOnRoot = mc2.mc3._x;


Perpetually looking for time to return to the arts.

BBS Signature
the1manwiththeplan
the1manwiththeplan
  • Member since: Jun. 10, 2008
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to HUD Question 2009-12-12 16:55:47 Reply

I think its pretty much explained but simply this is the way I do it

-If the text box had the var of score and you want it to say 5

_root.score=5;

-If you stuck the text box inside a movie clip with the instance name of "scoreMC"

_root.scoreMC.score=5;

If you want the score to follow the character round the stage say your characters instance name is "hero" put this AS on your scoreMC

onClipEvent (enterFrame) {
	if (_root.hero._x>_x) {
		_x += 1;
	}
	if (_root.hero._x<_x) {
		_x -= 1;
	}
	if (_root.hero._y>_y) {
		_y += 1;
	}
	if (_root.hero._y<_y) {
		_y -= 1;
	}
}

...

daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to HUD Question 2009-12-12 20:51:21 Reply


_root.scoreMC.score=5;

thanks this was what i was looking for something that would control the DTB inside th MC thanks much


My KKK name is Imperial Warrior

daytonj
daytonj
  • Member since: Jan. 9, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to HUD Question 2009-12-12 21:03:30 Reply

Yup 100% functional thanks much too bad it took almost 2 days!


My KKK name is Imperial Warrior