Highlighted

Fishing Game ActionScript 3.0

New Here ,
Jun 20, 2019

Copy link to clipboard

Copied

I am trying to make a fishing game where each fish you catch give you a point and different enemies subtract points. I have found a tutorial for this in ActionScript 2 but I can't find any for action script 3 (here is the link to what I want to replicate: Tutorials >> Games: Creating a fishing game using actionscript - Flash Kit ). I am relatively new at action script as I have only made animations before but I was able to a little but then couldn't figure out the rest. I currently have the fishing line moving up and down although it does not stay with the fishing rod and the hook won't go at the same time as the line. I also don't know how to make multiple of the same fish or enemies going across the screen at the same time.

Here is the code I have so far:

fish.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally);

function fl_AnimateHorizontally(event:Event)

{

  fish.x += 10;

}

var upPressed:Boolean = false;

var downPressed:Boolean = false;

var leftPressed:Boolean = false;

var rightPressed:Boolean = false;

rope.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);

stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);

function fl_MoveInDirectionOfKey(event:Event)

{

  if (upPressed)

  {

  rope.y -= 5;

  }

  if (downPressed)

  {

  rope.y += 5;

  }

  if (leftPressed)

  {

  rope.x -= 0;

  }

  if (rightPressed)

  {

  rope.x += 0;

  }

}

function fl_SetKeyPressed(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 fl_UnsetKeyPressed(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;

  }

  }

}

Any help would be great!

TOPICS
ActionScript

Views

124

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Fishing Game ActionScript 3.0

New Here ,
Jun 20, 2019

Copy link to clipboard

Copied

I am trying to make a fishing game where each fish you catch give you a point and different enemies subtract points. I have found a tutorial for this in ActionScript 2 but I can't find any for action script 3 (here is the link to what I want to replicate: Tutorials >> Games: Creating a fishing game using actionscript - Flash Kit ). I am relatively new at action script as I have only made animations before but I was able to a little but then couldn't figure out the rest. I currently have the fishing line moving up and down although it does not stay with the fishing rod and the hook won't go at the same time as the line. I also don't know how to make multiple of the same fish or enemies going across the screen at the same time.

Here is the code I have so far:

fish.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally);

function fl_AnimateHorizontally(event:Event)

{

  fish.x += 10;

}

var upPressed:Boolean = false;

var downPressed:Boolean = false;

var leftPressed:Boolean = false;

var rightPressed:Boolean = false;

rope.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);

stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);

function fl_MoveInDirectionOfKey(event:Event)

{

  if (upPressed)

  {

  rope.y -= 5;

  }

  if (downPressed)

  {

  rope.y += 5;

  }

  if (leftPressed)

  {

  rope.x -= 0;

  }

  if (rightPressed)

  {

  rope.x += 0;

  }

}

function fl_SetKeyPressed(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 fl_UnsetKeyPressed(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;

  }

  }

}

Any help would be great!

TOPICS
ActionScript

Views

125

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 20, 2019 0
Adobe Community Professional ,
Jun 21, 2019

Copy link to clipboard

Copied

Hi.

It seems the link you provided doesn't have a working sample.

Do you have one or a similar reference so we can understand better the type of fishing game you want to develop?

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 21, 2019 0