A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Screen movement

Threaded View

  1. #6
    Senior Member
    Join Date
    Jul 2002
    Posts
    184
    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.

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