Hey guys , Im new so I appologise for the question I’m also a fairly bad coder so If Im missing something obvious please help me.
I have a really basic platform game that goes moves and jumps - but I want the thing at the end to be clickable and take me to a frame labeled end - I get no errors and my mouse turns to a finger as if I can click it, but nothing happens. ender is the thing to click and ending is the page - the rest is it’s own thing.
my code:
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.media.Sound
import flash.display.SimpleButton
public class Dragonium extends MovieClip {
public var _startMarker:StartMarker;
public var _player:Hero;
public var _boundaries:Boundaries;
public var ending:Endpage;
public var ender:Endzone;
private var _vx:Number;
private var _vy:Number;
var w_h:wolf_howl = new wolf_howl
;
public function Dragonium():void {
// assign default values
_vx = 0;
_vy = 0;
_startMarker.visible = false;
ending = new Endpage;
ender = new Endzone;
// set focus for keyboard input
stage.focus = stage;
// add event listeners
this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
ender.addEventListener(MouseEvent.CLICK,onenderClick);
}
public function onenderClick(event:MouseEvent){
addChild(ender);
removeChild(_boundaries)
}
private function enterFrameHandler(e:Event):void {
// gravitate the player
_vy += 2;
// move the player
_player.x += _vx;
_player.y += _vy;
// process collisions
processCollisions();
// scroll the stage
scrollStage();
}
private function keyDownHandler(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37 :
_vx = -7;
_player.scaleX = -1;
break;
case 38 :
_vy = -20;
break;
case 39 :
_vx = 7;
_player.scaleX = 1;
break;
default :
}
}
private function keyUpHandler(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37 :
case 39 :
_vx = 0;
break;
default :
}
}
private function processCollisions():void {
// when player is falling
if (_vy > 0) {
// respawn if player fell off the stage
if (_player.y > stage.stageHeight) {
_player.x = _startMarker.x;
_player.y = _startMarker.y;
_boundaries.x = 0;
_boundaries.y = 0;
_vy = 0;
} else {
var collision:Boolean = false;
if (_boundaries.hitTestPoint(_player.x, _player.y, true)) {
collision = true;
}
if (collision) {
while (collision) {
_player.y -= 0.1;
collision = false;
if (_boundaries.hitTestPoint(_player.x, _player.y, true)) {
collision = true;
}
}
_vy = 0;
}
}
}
}
private function scrollStage():void {
_boundaries.x += (stage.stageWidth * 0.5) - _player.x;
_player.x = stage.stageWidth * 0.5;
_boundaries.y += (stage.stageHeight *0.5) - _player.y;
_player.y=stage.stageHeight*0.5
;
}
}
}