I want to set boundaries to my movie clip in flash with as3 so that the movie clip can't move out of the stage. How can i do this? This is the code that i have now. How i can now set the boundaries?
bij_mc.links_mc.play();
bij_mc.rechts_mc.play();
stage.addEventListener(KeyboardEvent.KEY_DOWN,beweeg);
stage.addEventListener(KeyboardEvent.KEY_UP,stopbeweeg);
function beweeg(evt:KeyboardEvent):void {
if (evt.keyCode==Keyboard.LEFT) {
bij_mc.links_mc.x -=10;
bij_mc.rechts_mc.x -=10;
bij_mc.lichaam_mc.x -=10;
bij_mc.links_mc.stop();
bij_mc.rechts_mc.play();
bij_mc.rotation = -5;
} else if (evt.keyCode==Keyboard.RIGHT) {
bij_mc.links_mc.x +=10;
bij_mc.rechts_mc.x +=10;
bij_mc.lichaam_mc.x += 10;
bij_mc.links_mc.play();
bij_mc.rechts_mc.stop();
bij_mc.rotation = 5;
} else if (evt.keyCode==Keyboard.UP) {
bij_mc.links_mc.y -=10;
bij_mc.rechts_mc.y -= 10;
bij_mc.lichaam_mc.y -= 10;
bij_mc.links_mc.play();
bij_mc.rechts_mc.play();
bij_mc.rotation = 0;
} else if (evt.keyCode==Keyboard.DOWN) {
bij_mc.links_mc.y +=10;
bij_mc.rechts_mc.y += 10;
bij_mc.lichaam_mc.y += 10;
bij_mc.links_mc.stop();
bij_mc.rechts_mc.stop();
bij_mc.rotation = 0;
}
}
function stopbeweeg(evt:KeyboardEvent):void {
bij_mc.links_mc.play();
bij_mc.rechts_mc.play();
bij_mc.rotation = 0;
}
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
private function onEnterFrame(event:Event):void
{
// update beweeg
checkBoundaries()
}
private function checkBoundaries():void
{
// left
if (bij_mc.x < 0)
bij_mc.x = 0;
// right
else if (bij_mc.x > stage.stageWidth)
bij_mc.x = stage.stageWidth - bij_mc.width;
// top
if (bij_mc.y < 0)
bij_mc.y = 0;
// bottom
else if (bij_mc.y > stage.stageHeight)
bij_mc.y = stage.stageHeight - bij_mc.height;
}
Update each movie clip accordingly.
Related
I'm trying to translate the following AS2 code into AS3 because I have Adobe Flash CC, which doesn't, as far as I know (from research, trial and error), support AS2 code. Any help would be greatly appreciated...
onClipEvent(load) {
speed = 0;
acceleration = 0.4;
speedDecay = 0.96;
maxSpeed = 10;
backSpeed = 1;
}
onClipEvent(enterFrame) {
if(Math.abs(speed) > 0.3) {
speed *= speedDecay;
}else {
speed = 0;
}
if(Key.isDown(Key.UP)) {
if (Math.abs(speed) >= maxspeed) {
speed += acceleration;
}
}
if(Key.isDown(Key.DOWN)) {
if(speed < 0.5)
speed = -2;
else
speed--;
}
if (Math.abs(speed)> 0.5) {
if (Key.isDown(Key.LEFT)) {
_rotation -= 10;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 10;
}
}
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.ground.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
}else {
speed -= speed*1.5;
}
}
This code goes in the Car layer of my car game.
Put this code inside your car's movieclip on frame 1:
var speed: Number = 0;
var acceleration: Number = 0.4;
var speedDecay: Number = 0.96;
var maxSpeed: Number = 10;
var backSpeed: Number = 1;
var pressedKeys: Object = {}
stage.addEventListener(Event.ENTER_FRAME, loop)
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown)
stage.addEventListener(KeyboardEvent.KEY_UP, keyup)
function keydown(e: KeyboardEvent) {
pressedKeys[e.keyCode] = true
}
function keyup(e: KeyboardEvent) {
if (pressedKeys[e.keyCode]) {
pressedKeys[e.keyCode] = false
}
}
function loop(e: Event) {
if (Math.abs(speed) > 0.3) {
speed *= speedDecay;
} else {
speed = 0;
}
if (pressedKeys[Keyboard.UP]) {
if (Math.abs(speed) >= maxSpeed) {
speed += acceleration;
}
}
if (pressedKeys[Keyboard.DOWN]) {
if (speed < 0.5)
speed = -2;
else
speed--;
}
if (Math.abs(speed) > 0.5) {
if (pressedKeys[Keyboard.LEFT]) {
this.rotation -= 10;
}
if (pressedKeys[Keyboard.RIGHT]) {
this.rotation += 10;
}
}
var vx: Number = Math.sin(this.rotation * (Math.PI / 180)) * speed;
var vy: Number = Math.cos(this.rotation * (Math.PI / 180)) * speed * -1;
if (!MovieClip(root).ground.hitTestPoint(this.x + vx, this.y + vy, true)) {
this.x += vx;
this.y += vy;
} else {
speed -= speed * 1.5;
}
}
can anybody tell me what is wrong with this code ...How to solve this code i use this code make monster move to the checkpoints...but all of the check points get some warning from Line 22-30 1136: Incorrect number of arguments. Expected 0.
package Game
{
import flash.display.MovieClip;
import flash.events.*;
import flash.geom.*;
public class Monster extends MovieClip
{
public var currLife:Number;
private var maxLife, gold, speed, currIndex, slowTimer:Number;
private var checkPoints:Array;
public function Monster()
{
maxLife = C.MONSTER_LIFE;
currLife = maxLife;
speed = C.MONSTER_SPEED;
currIndex = 0;
checkPoints = new Array();
checkPoints.push(new Point(85,140));
checkPoints.push(new Point(85,320));
checkPoints.push(new Point(325,320));
checkPoints.push(new Point(325,200));
checkPoints.push(new Point(265,200));
checkPoints.push(new Point(265,80));
checkPoints.push(new Point(505,80));
checkPoints.push(new Point(505,380));
checkPoints.push(new Point(630,380));
}
public function update()
{
var finalSpeed:Number;
if (slowTimer > 0)
{
finalSpeed = speed / 2;
slowTimer--;
}
else
finalSpeed = speed;
if (currIndex < checkPoints.length)
{
//move in the direction of the checkpoint
if (this.x < checkPoints[currIndex].x)
this.x += Math.min(finalSpeed, Math.abs(this.x -
checkPoints[currIndex].x));
else if (this.x > checkPoints[currIndex].x)
this.x -= Math.min(finalSpeed, Math.abs(this.x -
checkPoints[currIndex].x));
if (this.y < checkPoints[currIndex].y)
this.y += Math.min(finalSpeed, Math.abs(this.y -
checkPoints[currIndex].y));
else if (this.y > checkPoints[currIndex].y)
this.y -= Math.min(finalSpeed, Math.abs(this.y -
checkPoints[currIndex].y));
if ((this.x == checkPoints[currIndex].x) &&
(this.y == checkPoints[currIndex].y))
{
currIndex += 1;
}
}
//display
if (currLife > 0)
mcLifeBar.width = Math.floor((currLife/maxLife)*
C.LIFEBAR_MAX_WIDTH);
else
mcLifeBar.width = 0;
}
public function takeDamage(amtDamage)
{
if (this.currLife <= 0)
return;
this.currLife -= amtDamage;
if (this.currLife <= 0)
{
this.gotoAndPlay("death");
}
}
public function slowDown(amt)
{
slowTimer = amt;
}
public function hasReachedDestination()
{
return (this.currIndex == checkPoints.length);
}
}
}
Please help me to solve this problem ...i'm just a noob in AS3
i use that code in above for GameController.as
and this is update for GameController
public function update(evt:Event)
{
//Update the mobs
if ((currWave < maxWave) && (monsters.length == 0))
{
currWave++;
//spawn the monsters
spawnWave(currWave);
}
for (i=monsters.length - 1; i >= 0; i--)
{
if (monsters[i].currLife > 0)
{
monsters[i].update();
}
//Check if monster reaches the end of their path
if (monsters[i].hasReachedDestination())
{
monsters[i].gotoAndStop("remove");
life -= 1;
currGold -= C.MONSTER_GOLD;
}
if (monsters[i].currentLabel == "remove")
{
mcGameStage.removeChild(monsters[i]);
monsters.splice(i,1);
//Award Gold
currGold += C.MONSTER_GOLD;
}
}
//Update all the towers
for (i in towers)
{
towers[i].update();
}
//Update all the bullets
for (i=bullets.length - 1; i >= 0; i--)
{
bullets[i].update();
if (bullets[i].currentLabel == "remove")
{
mcGameStage.removeChild(bullets[i]);
bullets.splice(i,1);
}
}
//******************
//Handle Display
//******************
//Display new Score
mcGameUI.txtLife.text = String(life);
mcGameUI.txtGold.text = String(currGold);
mcGameUI.txtWave.text = String(currWave) + " / " + String(maxWave);
//Check for end game
if (life <= 0)
{
gameOver();
//stop all subsequent code in this update to run
return;
}
else if ((currWave == maxWave) && (monsters.length == 0))
{
gameWin();
}
}
private function spawnMonster(xPos, yPos)
{
var monsterToSpawn = new Monster();
monsterToSpawn.x = xPos;
monsterToSpawn.y = yPos;
monsters.push(monsterToSpawn);
mcGameStage.addChild(monsterToSpawn);
}
private function spawnWave(currWave)
{
if (currWave == 1)
{
spawnMonster(C.MONSTER_START_X, C.MONSTER_START_Y);
}
else if (currWave == 2)
{
for (i = 0; i < 2; i++)
{
spawnMonster(C.MONSTER_START_X - 40*i, C.MONSTER_START_Y);
}
}
}
Hi I don't understand why you are getting this error, but this can help you,
try the follow code instead of Point();
var checkPoints:Array=new Array({x:85,y:140},
{x:85,y:320},
{x:325,y:320},
{x:325,y:200},
{x:265,y:200},
{x:265,y:80},
{x:505,y:80},
{x:505,y:380},
{x:630,y:380}
);
I'm trying to complete background in kind of Space Invaders game. I want to generate stars at a random location, scroll them to the bottom of the stage and then add new star after each one is gone. I guess that the problem lies on the indexOf method, which I tried to use to find star y proprety.
I know this may be a stupid mistake, i'm a beginner :)
My current main class:
public class Main extends Sprite
{
private var ship:Ship = new Ship();
private var numStars:int = 80;
private var starArray:Array = new Array();
public function Main():void
{
stage.addChild(ship);
ship.x = stage.stageWidth / 2 - ship.width / 2;
ship.y = stage.stageHeight / 2 - ship.height / 2;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
for (var i:int = 0; i < numStars; i++)
{
createStar();
}
}
public function createStar():void
{
var newStar:Star = new Star();
starArray.push(newStar);
stage.addChildAt(newStar,1);
newStar.x = Math.random() * stage.stageWidth;
newStar.y = Math.random() * stage.stageHeight;
newStar.alpha = Math.random();
newStar.rotation = Math.random()*360;
newStar.scaleX = Math.random();
newStar.scaleY = Math.random();
}
public function keyDownHandler(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.UP)
{
ship.accelerationY = -0.3;
}
if (e.keyCode == Keyboard.DOWN)
{
ship.accelerationY = 0.3;
}
if (e.keyCode == Keyboard.LEFT)
{
ship.accelerationX = -0.3;
}
if (e.keyCode == Keyboard.RIGHT)
{
ship.accelerationX = 0.3;
}
}
public function keyUpHandler(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.UP || e.keyCode == Keyboard.DOWN)
{
ship.accelerationX = 0;
ship.accelerationY = 0;
}
if (e.keyCode == Keyboard.LEFT || e.keyCode == Keyboard.RIGHT)
{
ship.accelerationY = 0;
ship.accelerationX = 0;
}
}
public function enterFrameHandler(e:Event):void
{
//acceleration
ship.vx += ship.accelerationX;
ship.vy += ship.accelerationY;
//friction
ship.vx *= ship.friction;
ship.vy *= ship.friction;
if (Math.abs(ship.vx) < 0.1)
{
ship.vx = 0;
}
if (Math.abs(ship.vy) < 0.1)
{
ship.vy = 0;
}
ship.rotation = ship.vx * 2;
//set speed limit
if (ship.vx > ship.speedLimit)
{
ship.vx = ship.speedLimit;
}
if (ship.vx < -ship.speedLimit)
{
ship.vx = -ship.speedLimit;
}
if (ship.vy > ship.speedLimit)
{
ship.vy = ship.speedLimit;
}
if (ship.vy < -ship.speedLimit)
{
ship.vy = -ship.speedLimit;
}
//set stage boundaries
if (ship.x < 0)
{
ship.x = 0;
}
if (ship.y < 0)
{
ship.y = 0;
}
if (ship.x + ship.width > stage.stageWidth)
{
ship.x = stage.stageWidth - ship.width;
}
if (ship.y + ship.height > stage.stageHeight)
{
ship.y = stage.stageHeight - ship.height;
}
ship.x += ship.vx;
ship.y += ship.vy;
//star enter frame code
for (var i:int = 0; i < numStars; i++)
{
starArray[i].y += 0.5 + Math.random() * 2;
}
if (starArray.indexOf(starArray.y) > stage.stageHeight) //if y property of any star is higher than stage height, create a new star
{
createStar();
}
}
}
i recommend looking into tween utilities like TweenLite which do time based animations: (http://www.greensock.com/tweenlite/)
also recommend looking into object pooling, reused objects instead of creating new ones. Good thing to learn as a new programmer.
you are correct about where your issue lies
i got your program working correctly with the following change:
---------change these lines-------------
//star enter frame code
for (var i:int = 0; i < numStars; i++)
{
starArray[i].y += 0.5 + Math.random() * 2;
}
if (starArray.indexOf(starArray.y) > stage.stageHeight) //if y property of any star is higher than stage height, create a new star
{
createStar();
}
---------to this-------------
//star enter frame code
for (var i:int = 0; i < numStars; i++)
{
var star:Star = starArray[i];
star.y += 0.5 + Math.random() * 2;
if (star.y>stage.stageHeight){
//dont create a new star -- memory leak
//move the same star to a new random location
star.y = 0;
}
}
Instead of just creating a new star, why not just replace it at the top outside of the screen?
As for indexOf, it only returns the index in an array of the object being passed. And in this case you're passing the y value of an array, which doesn't have that property.
Instead, move your position checking code to your for loop in the game loop. That way, you already have an index (your i variable) of the star that's outside the boundaries and if it is, just reposition it and save some memory!
for (var i:int = 0; i < numStars; i++)
{
starArray[i].y += 0.5 + Math.random() * 2;
if(starArray[i].y > stage.stageHeight)
{
// Repositions the star between x: 0 to stageWidth, y: -5 to -15
starArray[i].y = Math.random() * -10 - 5;
starArray[i].x = Math.random() * stage.stageWidth;
}
}
Ok i want my button to only be clickabe once it is visibe, it is invisible til you win the game(1 score of pong)
here is what i have
var buttonsStates:Object = {
"scoreBoard_W" : false
};
function checkVisibility () {
for (var scoreBoard_W:String in buttonsStates) {
if(visible == true)
{
scoreBoard_W.addEventListener(MouseEvent.CLICK, goto3);
function goto3(Event:MouseEvent)
{
gotoAndStop(1,"Menu");
}
and here is the error: Pong, Layer 'Pong', Frame 2, Line 129 1061: Call to a possibly undefined method addEventListener through a reference with static type String.
im not sure what it means, or if im on the right track any help is apperciaed
Here is all of the code
stop();
var buttonsStates:Object = {
"scoreBoard_W" : false
};
var ballSpeedX:int = -3;
var ballSpeedY:int = -2;
var cpuPaddleSpeed:int = 3;
var playerScore:int = 0;
var cpuScore:int = 0;
scoreBoard_W.visible = false;
scoreBoard_L.visible = false;
init();
function init():void
{
stage.addEventListener(Event.ENTER_FRAME, loop);
}
function calculateBallAngle(paddleY:Number, ballY:Number):Number
{
var ySpeed:Number = 5 * ((ballY - paddleY) / 25);
return ySpeed;
}
function updateTextFields():void
{
playerScoreText.text = ("Player Score: " + playerScore);
cpuScoreText.text = ("CPU Score: " + cpuScore);
}
function loop(e:Event):void
{
if (playerPaddle.hitTestObject(ball) == true)
{
if (ballSpeedX < 0)
{
ballSpeedX *= -1;
ballSpeedY = calculateBallAngle(playerPaddle.y, ball.y);
}
}
else if (cpuPaddle.hitTestObject(ball) == true )
{
if (ballSpeedX > 0)
{
ballSpeedX *= -1;
ballSpeedY = calculateBallAngle(cpuPaddle.y, ball.y);
}
}
if (cpuPaddle.y < ball.y - 10)
{
cpuPaddle.y += cpuPaddleSpeed;
}
else if (cpuPaddle.y > ball.y + 10)
{
cpuPaddle.y -= cpuPaddleSpeed;
}
playerPaddle.y = mouseY;
if (playerPaddle.y - playerPaddle.height / 2 < 0)
{
playerPaddle.y = playerPaddle.height / 2;
}
else if (playerPaddle.y + playerPaddle.height/2 > stage.stageHeight)
{
playerPaddle.y = stage.stageHeight - playerPaddle.height / 2;
}
ball.x += ballSpeedX;
ball.y += ballSpeedY;
if (ball.x <= ball.width / 2)
{
ball.x = ball.width / 2;
ballSpeedX *= -1;
cpuScore++;
updateTextFields();
}
else if (ball.x >= stage.stageWidth-ball.width/2)
{
ball.x = stage.stageWidth - ball.width / 2;
ballSpeedX *= -1;
playerScore++;
updateTextFields();
}
if (ball.y <= ball.height / 2)
{
ball.y = ball.height / 2;
ballSpeedY *= -1;
}
else if (ball.y >= stage.stageHeight-ball.height/2)
{
ball.y = stage.stageHeight - ball.height / 2;
ballSpeedY *= -1;
}
if (playerScore >= 1)
{
stage.removeEventListener(Event.ENTER_FRAME, loop);
scoreBoard_W.visible = true;
}
if (cpuScore >= 1)
{
stage.removeEventListener(Event.ENTER_FRAME, loop);
scoreBoard_L.visible = true;
}
}
Mouse.hide();
mywelcome.text = "Good Luck, " + myName;
function checkVisibility () {
for (var scoreBoard_W:String in buttonsStates) {
if(visible == true)
{
scoreBoard_W.addEventListener(MouseEvent.CLICK, goto3);
function goto3(Event:MouseEvent)
{
gotoAndStop(1,"Menu");
}
}
}
}
The problem is in this line
scoreBoard_W.addEventListener(MouseEvent.CLICK, goto3);
As you using for (var scoreBoard_W:String in buttonsStates){...} inside definition of function function checkVisibility () {...} you declare local String-type variable which block your access to button with same name.
Changing
scoreBoard_W.addEventListener(MouseEvent.CLICK, goto3);
to
this.scoreBoard_W.addEventListener(MouseEvent.CLICK, goto3);
will do the trick.
Im attempting to make a basic maze game with a slight twist. At set intervals (set by a timer event) the maze rotates 90%. The problem I'm having is in regards to the hitTestPoint. The hit test works prior to the maze roataion and works after a full 360% rotation but stops working during the 90%, 180% and 270% rotation points. I have exhausted all my knowledge (As limited as a 5 month AS3 programmer) in AS3 to resolve this problem and am at my wits end.
The maze is in a container and the container is rotating, this is so that the maze in effect has a secondary moving pivot point that continually follows the player around tha maze. additionally the container is moving on key press not the player.
Could anyone please halp me by explaining what is causing the problem, how I can fix it and if possible show me an example of the code I should be using.
Here is what I have so far.
stop();
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.sensors.Accelerometer;
var speed:Number = 5;
var northSpeed = speed;
var southSpeed = speed;
var eastSpeed = speed;
var westSpeed = speed;
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var Orientation:int = 0;
var count:int = 0;
var timer:Timer = new Timer(1000,60);
var time = 60;
player.addEventListener(Event.ENTER_FRAME, MovePlayer);
containBox.maze.addEventListener(Event.ENTER_FRAME, hitWalls);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyDepressed);
containBox.maze.addEventListener(Event.ENTER_FRAME, spin);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerHandle);
function timerHandle(e:TimerEvent):void
{
txt_time.text = time;
time--;
}
function hitWalls(event:Event):void
{
if (upPressed==true && containBox.maze.hitTestPoint(player.x,player.y,true))
{
northSpeed = 0;
player.y = player.y+=2;
}
else
{
northSpeed = speed;
}
}
function spin(event:Event):void
{
if (time <= 0)
{
txt_time.text = "TIMES UP!";
}
if (time <= 54)
{
containBox.rotation = 90;
Orientation = 1;
}
if (time <= 50)
{
containBox.rotation = 180;
Orientation = 2;
}
if (time <= 48)
{
containBox.rotation = 270;
Orientation = 3;
}
if (time <= 46)
{
containBox.rotation = 0;
Orientation = 0;
}
}
function MovePlayer(event:Event):void
{
if (Orientation == 0)
{
if (upPressed)
{
containBox.maze.y += northSpeed;
}
if (downPressed)
{
containBox.maze.y -= southSpeed;
}
if (leftPressed)
{
containBox.maze.x += westSpeed;
}
if (rightPressed)
{
containBox.maze.x -= eastSpeed;
}
}
else if (Orientation == 1)
{
if (upPressed)
{
containBox.maze.x += 5;
}
if (downPressed)
{
containBox.maze.x -= 5;
}
if (leftPressed)
{
containBox.maze.y -= 5;
}
if (rightPressed)
{
containBox.maze.y += 5;
}
}
else if (Orientation == 2)
{
if (upPressed)
{
containBox.maze.y -= 5;
}
if (downPressed)
{
containBox.maze.y += 5;
}
if (leftPressed)
{
containBox.maze.x -= 5;
}
if (rightPressed)
{
containBox.maze.x += 5;
}
}
else if (Orientation == 3)
{
if (upPressed)
{
containBox.maze.y += 5;
}
if (downPressed)
{
containBox.maze.y -= 5;
}
if (leftPressed)
{
containBox.maze.x += 5;
}
if (rightPressed)
{
containBox.maze.x -= 5;
}
}
}
function KeyPressed(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP :
{
upPressed = true;
break;
};
case Keyboard.DOWN :
{
downPressed = true;
break;
};
case Keyboard.LEFT :
{
leftPressed = true;
break;
};
case Keyboard.RIGHT :
{
rightPressed = true;
break;
}
}
}
function KeyDepressed(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP :
{
upPressed = false;
break;
};
case Keyboard.DOWN :
{
downPressed = false;
break;
};
case Keyboard.LEFT :
{
leftPressed = false;
break;
};
case Keyboard.RIGHT :
{
rightPressed = false;
break;
}
}
}
Many thanks,
Reece.
You need to do 2D coordinate system transformation to do a proper comparison. See, the player basically stands on a fixed point, thus (player.x, player.y) is fixed, and hitTestPoint() uses the coordinates supplied as local to the this object, in your case the maze. To get the player's coordinates in the maze's system, you need first get global position, then derive local position, there are functions for that, localToGlobal() and globalToLocal() respectively.
function hitWalls(event:Event):void
{
var p:Point=new Point(player.x,player.y);
var dp:Point=containBox.maze.globalToLocal(player.parent.localToGlobal(p));
// now test vs dp instead of player.
if (upPressed==true && containBox.maze.hitTestPoint(dp.x,dp.y,true))
{
northSpeed = 0;
player.y = player.y+=2;
}
else
{
northSpeed = speed;
}
}