| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
|
hi everybody
i got a problem in a game. my movie has the following dimensions: 550x400 px. i got a flying object (ship) in the movie. it shouldn't be possible to fly out of the stage. i created 4 clips around the stage and attatched the following script: this is for the left border: onClipEvent (enterFrame) { if (this.hitTest(_root.ship)) { _root.ship._x = _root.ship._x+12; } } it works like this, but not propperly !!! the "ship" gets "nervous" and it's quite difficult to get it out of the "hitTest" is there another way to stop my object on every side of my movie ??? i hope you'll understand what i mean... thanks in advance for you help!!!:-) |
|
|
|
|
|
#2 |
|
(@_@) -("pretty lights")
Join Date: Sep 2001
Location: the Netherlands
Posts: 3,988
|
U could include a piece of code stating that the _x of your ship may never be less than 0 + half the width of your ship (assuming that the registration point is in the center) and never more than 550 - half the width of your ship. The same for the _y, but with 400. Just include an if statement in your control code.
__________________
RicoD Link ? |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
|
thanks for your reply, could you post an example: do i have to attach the code to the ship ???
thanks a lot cuba |
|
|
|
|
|
#4 |
|
(@_@) -("pretty lights")
Join Date: Sep 2001
Location: the Netherlands
Posts: 3,988
|
exapmle :
Code:
on (keypress=<Right>){ //dunno the keypress thing at the moment, plz check
leftBorder = _root.myShip._width / 2;
rightBorder = 550 - leftMost;
if (_root.myShip._x >= leftMost && _root.myShip <= rightMost) {
// insert here the code that u use to move your ship right, depending on wether u want to take different things in account like speed, upgrades, gravity (?) etc.
}
__________________
RicoD Link ? |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
|
thanks, i'll try that...
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Card Match Game, Colour Me In Pictures and Board Game | Total Frigging | ActionScript 2.0 | 4 | 02-21-2005 01:04 AM |
| word search game with AS2 | black | General Chat | 5 | 08-12-2004 10:44 AM |
| [AS2] Tile game or not tile game? | krolben | Gaming and Game Development | 4 | 07-28-2004 01:41 PM |
| Game - freelancer required | fatherb | Projects and Positions | 6 | 07-18-2003 12:47 PM |