Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 346475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:10:49+00:00 2026-05-12T11:10:49+00:00

I am trying to create a platformer game and i am trying to make

  • 0

I am trying to create a platformer game and i am trying to make “player1” stop when it hits a “platform”. here is my code so far,

    gotoAndStop("gameStart");

import flash.display.MovieClip;
import flash.events.*;
import flash.ui.Keyboard;
import flash.ui.*;


import flash.utils.Timer;
import flash.events.TimerEvent;

player1.gotoAndStop("nothing");


 //private var speed:Number = 0;
 //private var maxspeed:Number = 4;

var myTimer:Timer = new Timer(10,0);


stage.focus = this;


player1.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
/*
myTimer.addEventListener(TimerEvent.TIMER,someFunction);



myTimer.start();

function someFunction(event:TimerEvent) {
 player1.y += 2;


}
*/

function setup() {
 stage.addEventListener(KeyboardEvent.KEY_DOWN, reactToArrowKeys);
}
setup();


function reactToArrowKeys(keyEvent:KeyboardEvent) {

 if (keyEvent.keyCode == 37) {

  if (player1.x > 0) {
   player1.x -= 5;
  }

 } else if (keyEvent.keyCode == 39) {

  if (player1.x < 700) {
   player1.x += 5;
  }

 }


}


function enterFrameHandler(e:Event):void {
   if (player1.hitTestObject(platform)) {
    trace("hitting");
   } else {
    player1.y += 4;
   }
  }

however the hitTestObject function (enterFrameHandler) does not work properly and will always take the “else” route.

please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:10:50+00:00Added an answer on May 12, 2026 at 11:10 am

    The code as posted works fine for me. I’d look for some other kind of silly mistake – for example, if you copied and pasted movie clips, you might have more than one clip on the stage named “platform”, in which case your reference may not resolve to the one you intend. Or something else along those lines.

    To track it down, try calling:

    trace( player1.getBounds(stage) );
    trace( platform.getBounds(stage) );
    

    which will tell you where Flash thinks the bounding boxes of those clips are. My guess is that code will return something other than what you’d expect, and resolving that discrepancy will show where the bug is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a 2D platformer (Mario-type) game and I am some
Background: Trying to make a simple drop the ball game. The code is located
Ok so I am trying create a login script, here I am using PHP5
I'm currently trying to make a basic platformer with XNA and I'm wondering how
I am trying to create a menu with PySide. This is the code def
I'm new to Blackberry. I use phonegap to create cross platform applications. I'm trying
I am working with the telerik reporting platform. I am trying to create a
I'm trying to create simple 2D action game, something similar to well known Fancy
I'm trying to create a JS-script to make modifications to add a footer to
I am trying create a WCF service that leverages the WPF MediaPlayer on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.