A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Screen movement

Threaded View

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Posts
    184

    [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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center