HUD Question
by Mike Q · in Technical Issues · 12/10/2008 (11:12 pm) · 1 replies
I am using TGB and I am trying to display a sprite in the top left corner measuring the PC's health that stays with the camera.
The way I set up my game is I dragged the level in different layers into the world builder and I have a camera movement behavior applied to the avatar that looks as follows:
My question is can someone type a behavior for me to make the healthbar stay with the camera as it moves?
The way I set up my game is I dragged the level in different layers into the world builder and I have a camera movement behavior applied to the avatar that looks as follows:
if (!isObject(Camera)) {
%template = new BehaviorTemplate(Camera);
%template.friendlyName = "Camera";
%template.behaviorType = "Camera";
%template.description = "Makes the camera follow this object";
%template.addBehaviorField(speed, "speed the camera follows (lower = faster)", float, 50.0);
}
function Camera::onBehaviorAdd(%this) {
sceneWindow2D.startCameraMove();
%this.owner.enableUpdateCallback();
}
function Camera::onUpdate(%this) {
sceneWindow2D.setCurrentCameraPosition(
(getWord(sceneWindow2D.getCurrentCameraPosition(), 0) + ((%this.owner.getPositionX() - getWord(sceneWindow2D.getCurrentCameraPosition(), 0)) / %this.speed)),
(getWord(sceneWindow2D.getCurrentCameraPosition(), 1) + ((%this.owner.getPositionY() - getWord(sceneWindow2D.getCurrentCameraPosition(), 1)) / %this.speed))
);
}My question is can someone type a behavior for me to make the healthbar stay with the camera as it moves?
Associate Rene Damm