|
-
How can I do something like this?
Hey, this surely is a newbie question... but here it goes anyway:
I'm trying to make a simple rpg game and I would like to add something like a pop-up text box for the dialog that shows when the character interact with the npcs/items
(like on this game: http://www.mspaintadventures.com/?s=6&p=004692)
but I can't figure out how to do it.
I'm already using a text function that I learned on a tutorial but it isn't exactly what I wanted. I can't even open and close the text with the same key...
PHP Code:
onClipEvent (enterFrame) {
distance = 45;
ux = _root.char._x;
uy = _root.char._y;
hx = this._x;
hy = this._y;
if(Math.sqrt((ux-hx)*(ux-hx)+(uy-hy)*(uy-hy))<distance && Key.isDown(Key.SPACE)) {
_root.TextInstance.text = "text goes here";
}
if (Key.isDown(Key.SHIFT)) {
_root.TextInstance.text = "";
}
}
So I would really appreciate some help with this
If someone could link me to a tutorial or whatever that could help it would be awesome
-
Designer, Programmer, Musician
Hope this help.
Create 2 movieclips, one for main character and the other for another character. Name the main character main and the other man.
Create a dynamic textbox on stage and name it instance name statusTxt.
Put this script on your first frame
PHP Code:
var xSpeed=4; var ySpeed=4 main.onEnterFrame=function(){ radius=8; if(this.hitTest(man)){ if(Key.isDown(Key.SPACE)){ statusTxt.text="Save? Yes(Y) No(N)"; } if(statusTxt.text==""){ } else { if(Key.isDown (89)){ statusTxt.text="Saved Successfully."; } if(Key.isDown(78)){ statusTxt.text="Remember saving your game later!"; } } } else { statusTxt.text=""; }
if (Key.isDown(Key.DOWN) &&Key.isDown(Key.UP) ){ this.ySpeed = 0
} else if (Key.isDown(Key.UP)){ this.ySpeed = -5 this.gotoAndStop("walking"); } else if (Key.isDown(Key.DOWN)){ this.ySpeed= +5 this.gotoAndStop("walking"); } else { this.ySpeed=0 } if (Key.isDown(Key.LEFT) && Key.isDown(Key.RIGHT)){ this.xSpeed = 0 } else if (Key.isDown(Key.RIGHT)){
this.xSpeed = +5 this.gotoAndStop("walking"); } else if (Key.isDown(Key.LEFT)){ this.xSpeed = -5 this.gotoAndStop("walking"); } else { this.xSpeed =0 } if (this.xSpeed ==0 && this.ySpeed ==0){
this.gotoAndStop("stand"); } this._x += this.xSpeed; this._y += this.ySpeed; while (man.hitTest (this._x, this._y+radius, true)){ this._y--; this.gotoAndStop("stand"); } while (man.hitTest (this._x, this._y-radius, true)){ this._y++; this.gotoAndStop("stand"); } while (man.hitTest (this._x-radius, this._y, true)){ this._x++; this.gotoAndStop("stand"); } while (man.hitTest (this._x+radius, this._y, true)){ this._x--; this.gotoAndStop("stand"); } };
 Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries 
-
Designer, Programmer, Musician
Move the character with keyboard arrows, then when close to the man movieclip, hit SPACE aand then Y and N. I can add more things if you want, so it fits what you need.
 Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|