|
-
[HELP] Screen movement
okay ... I have a game i'm trying to make a rough engine for ... and I'd like some screen motion ... let me explain
I have a viewable area of 550 x 400 but would like the actual stat be about 1650 x 1200. So basically a 3x3 square of 550 x 400. Now I would liek the screen to move with my hero unless it is on the edge ...
Code:
|_a_|_b_|_c_|
|_d_|_e_|_f_|
|_g_|_h_|_i_|
Okay lets say that is the set up ... I'm in "e" if i walk towards "d" the viewable area move to the left untl all of "d" is viable and then my hero just moves towards the wall withouth the screen moving.
I hope I explained this right. Any help is appreciated...
oh yeah this is what I got so far http://fable.abuseadam.com/town.html. Signs and items can be looked at with SPACE by the by.
My hero moves with this code from Ed Mack(?) inthe hittest topic:
Code:
onClipEvent(load){
s = 10;
r = 5;
b = this.getBounds(this);
function move(x,y){
if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)){
if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)){
if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)){
if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)){
_x += x;
_y += y;
}
}
}
}
}
}
onClipEvent(enterFrame){
if(Key.isDown(Key.UP)){
move(0,-s);
}
if(Key.isDown(Key.UP) && Key.isDown(Key.CONTROL)){
move(0,-r);
}
if(Key.isDown(Key.DOWN)){
move(0,s);
}
if(Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL)){
move(0,r);
}
if(Key.isDown(Key.LEFT)){
move(-s,0);
}
if(Key.isDown(Key.LEFT) && Key.isDown(Key.CONTROL)){
move(-r,0);
}
if(Key.isDown(Key.RIGHT)){
move(s,0);
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.CONTROL)){
move(r,0);
}
}
Last edited by ashmills; 06-11-2004 at 10:13 AM.
-
Hype over content...
The effect you want is called "Scrolling". Have a search, you'll find a zillion threads about it, honestly 
Squize.
-
yes this I knwo ... I did a search and found mostly them saying make the BG move instead of the hero ... alright great idea, but I don't think It works in my case ... tell me if I'm wrong...
I have 2 Issues with this, my first:
I have multiple layers.
A BG Layer: All the objects the hero can walk on.
A MAP Layer: All the stop points the hero can't walk on.
A ROOF Layer: All the object the hero walk behind/under.
A HIT Layer: Hit points for all the object the hero can interact with.
In those layers lie X amounts of items. In order to do this technique all of these items would have to move instead of the hero.
2nd Issue being that I want the hero to move not the screen when the screen comes to an "END" point. Now I assume I just make the screen and hero move at the same rate at all times except when the "END" point comes up, then the screen moves and the hero doesn't ... not of the topics I read delt with these issues ... Further help would be appreciate...
Also ... doesn't anyone know how to pass a form value in a html page to a dynamic text box in Flash? I tried something like
Code:
<script LANGUAGE="JavaScript">
<!--
function pass_to_flash()
{
document.town.name.text = document.charform.name.value;
}
//-->
</script>
needless to say that didn't work.
-
have a look at tonypas tile based tutorial. I think he explain it there.
passing a vatiable into flash:
Code:
window.document.[name of movie].SetVariable("/mc/variable",value);
-
Hype over content...
ashmills, you've got all the different layers in container mc's ? If that's the case then just moving the containers will scroll the screen ( Just put the player on it's own layer so it doesn't scroll ).
Then when the background scrolls as far as it can you then just use the normal player._x+=speed to move him.
Squize.
-
alright I made them all containers and can make them move ... but I think because of the way I do my hit test ... if the walls touch my hero they go right through him cause he isn't moving everythign else is ... hmm should I use a different hit test or is their away to work around it...
I put this on the objects ...
Code:
onClipEvent(load){
s = 10;
r = 5;
b = _root.hero.getBounds(this);
function move(x,y){
if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)){
if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)){
if(!_root.hit.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)){
if(!_root.hit.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)){
_x += x;
_y += y;
}
}
}
}
}
}
onClipEvent(enterFrame){
if(Key.isDown(Key.UP)){
move(0,-s);
}
if(Key.isDown(Key.UP) && Key.isDown(Key.CONTROL)){
move(0,-r);
}
if(Key.isDown(Key.DOWN)){
move(0,s);
}
if(Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL)){
move(0,r);
}
if(Key.isDown(Key.LEFT)){
move(-s,0);
}
if(Key.isDown(Key.LEFT) && Key.isDown(Key.CONTROL)){
move(-r,0);
}
if(Key.isDown(Key.RIGHT)){
move(s,0);
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.CONTROL)){
move(r,0);
}
}
hoping tat when the hero touched map all woudl stop ... but needless to say it didn't work
oh yeah and thanks for the JS thing ... i figured it out as soon as the email got sent ot me that you posted ^_^.
Last edited by ashmills; 06-11-2004 at 11:03 AM.
-
I know I'm being annoying and I'm sorry,
i've been working on this all morning ... and still no luck on the scrolling thing ... my hero just moves through walls when I move the screen insted of him ... I would like to use the hittest method I am using as it serves my purpose extremely well but I can't seem to get it to work with this scrolling feature ... if someone could help me further it would be appreciated...
I'll give a link to the FLA for those who might need it to help..
http://Fable.AbuseAdam.com/town.fla
-
oh yeah an by the by even though it looks to be tile based at the moment it more than likely will be more art based once I get the basics working ... it is just tile based lookign ot get the basics going. I would like the hit test I do for that reason, I can block of many types of shapes and what not.
-
alright ... this is where I am at
http://fable.abuseadam.com/townscroll.html
and here is the fla incase someone wants to help...
http://fable.abuseadam.com/townscroll.fla
I'd appreciate any help ... I sure as hell can't figure out how to make the wall hit test still work, or make the scroll stop and my reg walk beging again when I get near an edge ... I appreciate any help in advance...
Walk SE to find the town with walls and fences and the such.
I know why it is happening but not how to fix it. It is happening cause my hero isn't moving the bg is ... so the hit test doesn't succesfully connect for some reason ... must be the way I check ... I guess I'd have to do the hittest with map instead and when it hits hero ... then do my stops? hmm I'm gonna try ... like i said any help is appreciated.
Last edited by ashmills; 06-11-2004 at 04:18 PM.
-
Okay ...as you can see from the updated fla I tried to do a hit test with the walls on hero movie clip ... but it doesn't seem to work ...
code:
onClipEvent(load){
s = 10;
r = 5;
b = _root.map.getBounds(_root.map);
function move(x,y){
if(!_root.hero.hitTest(_x+x+b.xmin+1, _y+y+b.ymin+1, true)){
if(!_root.hero.hitTest(_x+x+b.xmax-1, _y+y+b.ymin+1, true)){
if(!_root.hero.hitTest(_x+x+b.xmin+1, _y+y+b.ymax-1, true)){
if(!_root.hero.hitTest(_x+x+b.xmax-1, _y+y+b.ymax-1, true)){
_x += x;
_y += y;
}
}
}
}
}
}
onClipEvent(enterFrame){
if(_root.scroll == "true")
{
if(Key.isDown(Key.UP)){
move(0,s);
}
if(Key.isDown(Key.UP) && Key.isDown(Key.CONTROL)){
move(0,r);
}
if(Key.isDown(Key.DOWN)){
move(0,-s);
}
if(Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL)){
move(0,-r);
}
if(Key.isDown(Key.LEFT)){
move(s,0);
}
if(Key.isDown(Key.LEFT) && Key.isDown(Key.CONTROL)){
move(r,0);
}
if(Key.isDown(Key.RIGHT)){
move(-s,0);
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.CONTROL)){
move(-r,0);
}
}
}
I don't knwo what else to do ... hmm i'll keep trying..
-
welp I the moron just realized I was refering to my walls as map ... when they are indeed hit ... so anyhow I've gotten a step closer ... Not it works just fine, but when I'm in the town it thinks I'm still hitting the mc so ... it doesn't scroll I think I can fix that ...
but if you want to tell me how go right ahead.
Last edited by ashmills; 06-11-2004 at 06:02 PM.
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
|