Hello all. I just joined the forum because it comes up so much in my searches I figured why not! Here is my issue, hopefully someone can help.
I am working on a side-scroller flash AS2 video game. I currently have a vcam set up with some code like this in it.
onClipEvent (enterFrame) {
_y += (_root.char._y-_y);
_x += (_root.char._x-_x);
}
This basically makes the vcam follow the character.
I also have a health bar I have attached like this.
onClipEvent (enterFrame) {
this._x = _root.char._x-200;
this._y = _root.char._y-210;
}
this makes the health bar stay on the screen within the vcam in relation to where the character is.
My first problem is, how do I do this same thing to dynamic text boxes? I have 2 dynamic text boxes (1 is a name which comes from an input text box on start screen. The other is the actual number of health points remaining. How do I attach these dynamix text boxes to the vcam? or in relation to the player so they are laid out like a hud next to the health bar?
My second question.
I have also created an inventory system and some objects. Basically what happens is when the character picks up an item such as a potion or weapon, it goes up into the inventory slots.
This is the inventory code
currentslotnum = 1;
stop();
function addToSlot(item){
if(!item.found){
item._x = eval (“itemslot” + currentslotnum)._x;
item._y = eval (“itemslot” + currentslotnum)._y;
item.found = true;
currentslotnum++;
}
}
This is the code on items
onClipEvent (enterFrame) {
if (_root.char.hitTest(this)) {
_root.addToSlot(this);
}
}
It all works great but the problem is, I have attached the inventory slots to the hud using the same method as i did for the health bar. So, now when an item is picked up it goes to the inventory slot, but as soon as the character moves the slot moves, but the item just stays sitting in the original area the slot was in. The items get picked up, they just do not stay in slot attached to vcam. They go in slot and stay suspended in same area even after vcam has moved with slots health bar and character. How do I make the items stay in slot after pick up in vcam?
here is the code on the actual inventory slots.
onClipEvent (enterFrame) {
this._x = _root.char._x-275;
this._y = _root.char._y-165;
}
it just makes inventory slots stay in vcam relative to character.
If anyone can help with any of these issues let me know.