Thanks for the great tutorials, I have found a slight problem with your finished game. I am not sure if your aware that, you can just position your avatar off the screen and none of the enemies can attack you.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AvoiderGame()
at DocumentClass/onRequestStart()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at MenuScreen/onClickStart()
Whenever i try to click that above and also when i download the source files it gives me that error… any idea on how to fix this?
To make it move diagonal you have to make left,right,up, and down boolean fucntions.
Here is some pseudo code for an Idea:
var left:Boolean = false;
var right:Boolean = false;
var up:Boolean = false;
var down:Boolean = false;
var speed:Number = 5;
function keyTrue(event:KeyboardEvent)
{
if(charCode == 37) //or keyCode I forget which one works the best
{
left = true;
}
//do this for all charCodes 37 – 40 left-37 up-38 right-39 down-40
//Play around with else if’s and if’s to play around with the logic so you can understand it better
}
function keyFalse(event:KeyboardEvent)
{
if(charCode == 37)
{
left = false;
}
//again for all of them.
}
function boolListen(event:Event)
{
if(left == true)
{
player.x += speed
}
//for all charCodes.
// this one I believe should ALL be if’s, no else if’s or else only one at a time will work.
}
{ 14 comments… read them below or add one }
Hi,
Thanks for the great tutorials, I have found a slight problem with your finished game. I am not sure if your aware that, you can just position your avatar off the screen and none of the enemies can attack you.
thanks
Cheers Chris!
Yep, it’s true. I didn’t notice that at first, but I left it in because I think it’s a good challenge to work out how to fix it yourself
Whenever i try to click that above and also when i download the source files it gives me that error… any idea on how to fix this?
My score is 1880
Score: 1950. Seconds: 45.
you r a lier cuz the top score is 1880
sorry but it looks like i win ;D
@abdulhadi
The high score is stored on your own computer, so no one else’s scores will show up.
1980 lol, looks like I’m winning.. Although I seriously doubt that
weow 1650 mike tyson ur looking the good and munners u smell
HI, pretty good game but how can I make it to move on diagonal? D:
To make it move diagonal you have to make left,right,up, and down boolean fucntions.
Here is some pseudo code for an Idea:
var left:Boolean = false;
var right:Boolean = false;
var up:Boolean = false;
var down:Boolean = false;
var speed:Number = 5;
player.addEventListener(KeyboardEvent.KEY_DOWN, keyTrue);
player.addEventListener(KeyboardEvent.KEY_UP, keyFalse);
stage.addEventListener(Event.ENTER_FRAME, boolListen);
function keyTrue(event:KeyboardEvent)
{
if(charCode == 37) //or keyCode I forget which one works the best
{
left = true;
}
//do this for all charCodes 37 – 40 left-37 up-38 right-39 down-40
//Play around with else if’s and if’s to play around with the logic so you can understand it better
}
function keyFalse(event:KeyboardEvent)
{
if(charCode == 37)
{
left = false;
}
//again for all of them.
}
function boolListen(event:Event)
{
if(left == true)
{
player.x += speed
}
//for all charCodes.
// this one I believe should ALL be if’s, no else if’s or else only one at a time will work.
}
hehe i’m the best! did 2190!
Nice tutorial!
Gj!
mine? 100000! oh yeah
Cheers, Michael! Thanks for your tutorials!
{ 4 trackbacks }