Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-05-2010, 08:52 PM   #1
eivind
Registered User
 
Join Date: Oct 2010
Posts: 5
Question [AS2] Move everything

/*
Hi, I'm trying to create a game (as always), what goes very well (also as always), but I got a problem (believe it or not, this is also like it always have been...). The problem is that I want to move everything else, instead of my character, to make it possible to explore larger maps than the screen. My code works fine - but only on the y-axis, I'm really confused! Here is the code that moves the world:
*/

onClipEvent (enterFrame) {

//Stores original coordinates
OldX1 = _x;
OldX2 = _root.hitTester._x;
OldY1 = _y;
OldY2 = _root.hitTester._y;
OldX3 = _root._x;
OldY3 = _root._y;
OldRot =_rotation;

//Handles the key input
if (Key.isDown(65)) {
this._x -= 7;
_root.hitTester._x -= 7;
_root._x += 7;
}
if (Key.isDown(68)) {
this._x += 7;
_root.hitTester._x += 7;
_root._x -= 7;
}
if (Key.isDown(87)) {
this._y -= 7;
_root.hitTester._y -= 7;
_root._y += 7;
}
if (Key.isDown(83)) {
this._y += 7;
_root._y -= 7;
_root.hitTester._y += 7;
}
//Checks if you hit a wall, if you do, reset the coordinates to the original ones
this._rotation = Math.round((Math.atan2(_root._xmouse - this._x, _root._ymouse - this._y)*-180/Math.PI)) +47;
for(var wall=1; wall <= _root.TotalWalls; wall++) {
if (_root.hitTester.hitTest("_root.Wall" + wall)) {
_x = OldX1;
_y = OldY1;
_root._x = OldX3;
_root._y = OldY3;
_root.hitTester._x = OldX2;
_root.hitTester._y = OldY2;
}
if (WeaponEnd.hitTest("_root.Wall" + wall)) {
_rotation = OldRot;
}
}
}

/*
Thanks for helping
*/
eivind is offline   Reply With Quote
Old 11-09-2010, 04:52 PM   #2
Scearezt
Satisfied User
 
Scearezt's Avatar
 
Join Date: Jun 2010
Location: C:\\System32\Hungary
Posts: 426
Lightbulb

Um... try to write your codes into the main timeline, easier to controll your movieclips and harder to confuse in it also you know where can you find your code....

Also why don't you use vcam instead of moving the whole map? Man you're brave

Just tips.
Scearezt is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:19 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.