Skip to main content
Participant
June 21, 2019
Question

Fishing Game ActionScript 3.0

  • June 21, 2019
  • 1 reply
  • 321 views

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!

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
June 21, 2019

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