How to make player interact with game world objects?

I am trying to make a side scrolling rpg game similar to South Park Stick of Truth. Right now I have the player done and i sketched the outline of the room i wanted in order to test the the collision detector. So right now there are only 4 classes. The main class that adds the walls, player and does something with the constants class.The walls class that doesn't really do anything. The player class that moves with keyboard input, test for collisions with the walls and initiates the walking animation. There is also a constants class that i don't really know how it works but based on tutorials I have seen they want me to use it. I want to add different things in the room that when the player gets close enough to, it allows the person playing to press a button and it will interact with it. It could be for making a small animation, having the player do some different dialog or have a closer look at the object. I can't find any tutorial on how to do that. All the actionscript 3 tutorials are for really simple shooter and platform games that don't interact with the game world at all. Any help would be greatly appreciated.

You could make all of your "interactable" objects implement an interface. Say for example your Interface defines showButton() and hideButton() functions. Then, when you detect a collision on any of these objects, you call showButton(). The button can be set up to dispatch an event that your Main Class is listening for. For example, this might be a custom MoreInfoEvent that has its own "infoItem" property in addition to the other properties Event has.
The code might look like this:
protected function onButtonClick(e:MouseEvent):void {
     dispatchEvent(new MoreInfoEvent(MoreInfoEvent.SHOW_INFO, true, "rockObject"));
Then the MainClass would do something like this:
protected function onMoreInfoEvent(e:MoreInfoEvent):void {
     switch(e.infoItem) {
          case "rockObject":
               rockInfo.visible=true;
               break;
          //other case statements for other info
          default:
               break;
If you don't know how to create a custom event, there are a lot of tutorials for that.

Similar Messages

  • How to Make a Multi-Level Game in Flash 5

    I'm wanting to know, "How to Make a Multi-Level game with
    Flash 5"? EX: If I were to make a space game, where after reaching
    a score of 2000 points, the game pauses and displays the text
    "Stage 2", then continues or provides a button to make the game
    continue starting on stage 2. Any help with this question is
    grately appreciated.
    coolburn

    coolburn wrote:
    > I'm wanting to know, "How to Make a Multi-Level game
    with Flash 5"? EX: If I
    > were to make a space game, where after reaching a score
    of 2000 points, the
    > game pauses and displays the text "Stage 2", then
    continues or provides a
    > button to make the game continue starting on stage 2.
    Any help with this
    > question is grately appreciated.
    >
    > coolburn
    First off.. Flash 5 is like.. Ancient. Dude. Seriously, thats
    more than
    3 versions ago, and there have been major major changes
    since.
    However, I'll give it a try..
    First off, there has to be some kind of an event that kicks
    it off. I
    would build something into the score system that would
    trigger this.
    For example.
    function updateScore():Void {
    _root.stage.scoreboard.text = myNewScore;
    if (myNewScore > 2000) {
    jumpToNextLevel();
    So, somewhere in your game a variable keeps the score.. if
    your game
    runs the updateScore function once in a while, if it hits
    more than
    2000, it triggers a new function called jumpToNextLevel.
    In the jumpToNextLevel, you would have to do more functions
    like
    pauseTheGame(), and such..
    In general.. break it down to small pieces of what you want
    to do. Each
    function would do a series of things.. Then when your going
    though your
    game, you call each function as needed.
    Hope this helps
    -Bill

  • How to make an interactive block ALV

    Hi,
       I am new to the field of ABAP and have recently started working on ALV's. My problem is that i do not know how to make an interactive block ALV. I have implemented this functionality with the simple ALV but I am not getting the same for block ALV. Anyone who has worked on the same or has any idea please help me.
    Regards.
    Alok Bhardwaj

    Hi jester526,
    You'll need Acrobat to create links in a PDF file. Please see https://acrobatusers.com/tutorials/creating-and-editing-links for instructions.
    Best,
    Sara

  • How to make this work with Firefox, HELP!

    Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • How to make text columns with adobe muse

    Hi,How to make text columns with adobe muse (like InDesign)?

    Multiple columns can be acheived with CSS - http://www.w3schools.com/css/css3_multiple_columns.asp
    div
    -moz-column-count:3; /* Firefox */
    -webkit-column-count:3; /* Safari and Chrome */
    column-count:3;
    I'm surprised that Muse does not support text columns yet, but perhaps the custom CSS can be added in style tags on page properties. Haven't tried it, but don't see why it wouldn't work.

  • How to make turning page with ibooks author?

    How to make turning page with ibooks author?

    This question has been answered on this thread
    https://discussions.apple.com/message/17981772#17981772#17981772
    Best regards.
    Alex

  • How to make maps interactive?

    hi, I have add to template in WAD map web item, but I dont know how to make maps interactive (filtering, drilldown in maps). I found some documentation which says:
    The following lines must be adjusted correctly to your individual system environment in the HTML code of the Web template.
    Example:
    <param name=’IMAGEMAP_PATTERN’ value=’FILTER_VAL’>
    <param name=’INFLUENCED_DP_1’ value=’Revenue Cockpit’>
    But I dont where i have to adjusted
    thanx for reply

    According tothe BI Functional Enhancement Schedule, this functionality will not be available until the following support pack stacks are released:
    <UL>
    <LI>Web Applications: Map toolbar (client-side interactivity &#56256;&#56518;zoom in, zoom out) standard + advanced toolbar (Stack 14)</LI>
    <LI>Web Applications: Save template parameters and context menu settings as reusable web item. Option to take this as default for all templates (Stack 15)</LI>
    <LI>Web Applications: context menu for map item (data cell relevant context menu entries only (Stack 12)</LI>
    <LI>Web Applications: context menu for map item (additionally characteristics cell relevant context menu entries (Stack 14)</LI>
    </UL>
    <a href="https://service.sap.com/~sapidb/011000358700004483762006E">URL to BI Functional Enhancement Guide</a>

  • How to make email link with a button with AC2 in flash cs3?

    How to make email link with a button with AC2 in flash cs3?
    I wrote this, but it does not work:
    btn_emailinfo.on (release) {
    getURL("mailto:"[email protected]");
    }

    I am guessing you put that on a frame?
    If so, the syntax is as follows:
    btn_emailinfo.onRelease = function(){
    getURL("mailto:[email protected]");
    Though, if you are placing it directly on the button itself,
    the syntax is:
    on(release){
    getURL("mailto:[email protected]");
    }

  • I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    It may be due to Continuity
    The following quote is from  Connect your iPhone, iPad, and iPod touch using Continuity
    Turn off iPhone cellular calls
    To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls.

  • In JSF, how to make a menu with access control?

    In JSF, how to make a menu with access control?
    The access control can be guided by programming, database or other means if possible?
    Thanks

    I want to make a dvd menu in iMovie because i don't have IDVD and can't find anywhere to download it?
    For making DVDs I would recommend iMovie 06 and iDVD 09 both readily available on Amazon or eBay.  Shop for iLife 06 and iLife 09.
    You can make menus and chapters with any version of iMovie except the latest one. There's nothing wrong with iMovie 11 either but I prefer iMovie 06.
    By using iMovie 06 and iDVD 09 I make DVDs with professional moving menus with very little effort. They look almost as good as Hollywood.

  • How to make slide images with Dreamweaver CS6?

    How to make slide images with Dreamweaver CS6? Please teach me.

    Hello
    in addition to Jon's hint, I'll send you some links to nice sliders (have fun with the different representations ):
    http://sandbox.scriptiny.com/javascript-slideshow/
    http://jquery.malsup.com/cycle/
    http://wowslider.com/best-jquery-slider-crystal-linear-demo.html
    http://www.jcoverflip.com/demo
    http://www.jacksasylum.eu/ContentFlow/
    http://addyosmani.com/blog/jqueryuicoverflow/
    You only need to use the source code to implant these shows there where you want. In my eyes it would be the best that you use first a very new and blank DW file to perform (maybe in LiveView) the one or the other.
    Hans-Günter

  • How to make fully interactive storyboard with videos, maps, audio????

    Hi there,
    I am looking for a tutorial or a walk through to make an interactive Storyboard with interactive maps, videos, audio files, play/pause button.
    And should be able to convert in multiple languages...
    I know its kindof difficult but not impossible.
    Thanks in advance.
    Janu

    use google to search:  flash <your as version> storyboard tutorial.

  • How to Make Multiplayer TCP Flash Game?

    I have a game in the works, and though I got the UDP to work perfectly, I sadly later found out that that is simply just a lossy protocol. There's apparently (as far as my knowledge goes) nothing you can do to make it resend data if the data was not received successfully by the recipient.
    So, I was wondering how to use TCP? I've heard it's possible, but I can't seem to find a single tutorial or any information anywhere on how to do it. I found on Adobe's site socket connections, and though I got the server to connect (I think), I have no clue how to send data to it, how to get other clients to connect to it, etc. Any help?
    This is the script I've been using, and though it does connect... that's basically all it does, I don't know where to go from here...
    package
        import flash.display.Sprite;
        import flash.events.EventDispatcher;
        import flash.events.Event;
        import flash.events.*;
        import flash.events.IOErrorEvent;
        import flash.events.ProgressEvent;
        import flash.events.ServerSocketConnectEvent;
        import flash.net.ServerSocket;
        import flash.net.Socket;
        public class TCP extends Sprite
            private var serverSocket:ServerSocket;
            private var clientSockets:Array = new Array();
            public function TCP()
                try
                    // Create the server socket
                    serverSocket = new ServerSocket();
                    // Add the event listener
                    serverSocket.addEventListener( Event.CONNECT, connectHandler );
                    serverSocket.addEventListener( Event.CLOSE, onClose );
                    // Bind to local port 8087
                    serverSocket.bind( 8087, "127.0.0.1" );
                    // Listen for connections
                    serverSocket.listen();
                    trace( "Listening on " + serverSocket.localPort );
                catch(e:SecurityError)
                    trace(e);
            public function connectHandler(event:ServerSocketConnectEvent):void
                //Thesocket is provided by the event object
                var socket:Socket = event.socket as Socket;
                clientSockets.push( socket );
                socket.addEventListener( ProgressEvent.SOCKET_DATA, socketDataHandler);
                socket.addEventListener( Event.CLOSE, onClientClose );
                socket.addEventListener( IOErrorEvent.IO_ERROR, onIOError );
                //Send a connect message
                socket.writeUTFBytes("Connected");
                socket.flush();
                trace( "Sending connect message" );
            public function socketDataHandler(event:ProgressEvent):void
                var socket:Socket = event.target as Socket
                //Read the message from the socket
                var message:String = socket.readUTFBytes( socket.bytesAvailable );
                trace( "Received: " + message);
                // Echo the received message back to the sender
                message = "Echo -- " + message;
                socket.writeUTFBytes( message );
                socket.flush();
                trace( "Sending: " + message );
            private function onClientClose( event:Event ):void
                trace( "Connection to client closed." );
                //Should also remove from clientSockets array...
            private function onIOError( errorEvent:IOErrorEvent ):void
                trace( "IOError: " + errorEvent.text );
            private function onClose( event:Event ):void
                trace( "Server socket closed by OS." );

    again:  unless you're using a server that all players connect to, you should be using adobe's peer-to-peer networking (rtmfp).
    ie, with multiplayer each player can communicate with a server and the server communicates with each player, or you use peer-to-peer communication.  below is an excerpt from a book i wrote (Flash Game Development: In a Social, Mobile and 3D World).
    Social Gaming - Multiplayer Games
    With multiplayer games, data needs to be communicated among the players.  When a player makes a move (changing the game state) the updated game state needs to be communicated to all the other players. In addition, that communication needs to occur in a timely manner. 
    With turn-based games (like card games) that communication among players can take as long as few seconds without degrading the game experience. With real time games (like shooter games), even a 250 millisecond delay in communicating game state leads to a significantly degraded player experience. Consequently, real time multiplayer games require substantial expertise to successfully develop and deploy.
    There are two fundamentally different ways that communication among players can be accomplished. Players can communicate via a server (server-based games) or they can communicate directly from player to player (peer-to-peer) games.
    Server Based Multiplayer Games
    Generally, the code in each player’s Flash game handles the player’s input, transmits player data to the server, receives other players' data and displays the game state. The server receives player data, validates the data, updates and maintains game state and transmits each player’s data to the other players.
    The code used on the server cannot be ActionScript so you will need to learn a server-side coding language like php or c#.  Server-side coding is beyond the scope of this book so I will not cover server-based multiplayer games except to say you need to have advanced coding skills in, at least, two languages (ActionScript and a server-side language) to create these game types.
    Peer-to-peer games
    Since Flash Player 10, you can create multiplayer games without the need of an intermediary server to facilitate player communication.  The Flash Player can use a protocol (Adobe's Real-Time Media Flow Protocol) that allows direct peer-to-peer communication.
    Instead of using server-side code to handle the game logic and coordinate game state among players, each peer in the network handles their own game logic and game state and communicates that directly to their peers and each peer updates their game state based on the data received from others.
    To use peer-to-peer networking each peer must connect with an Adobe server.  Peer-to-peer communication does not go through that server (or it that would not be peer-to-peer) but peers must stay connected with the Adobe server in order to communicate with each other.
    To communicate with the Adobe server you should use your own server URL and developer key. That URL and key can be obtained at http://www.adobe.com/cfusion/entitlement/index.cfm?e=cirrus.
    Below is a simple tic-tac-toe game that uses Adobe's peer-to-peer networking to pair-up players.  The NetConnection class is used to establish a connection to the Adobe server while the NetGroup class is used for peer-to-peer communication.
    I used only a small part of the NetGroup methods for the tic-tac-toe game but there are more available if you are sharing data among many users and/or sharing large amounts of data.
    The tic-tac-toe game is in support files/Chapter 11/multiplayer and is extensively commented

  • WHY is it that you cannot fix (completely so you never have to come back to it again) how adobe flash player works with windows 8.1?

    Hi,
    I would like to start a discussion on how one of the "leading" software companies in the WORLD cannot provide a better way for their software (which I assume they want everyone to use) to be used in conjunction with windows 8.1.   ADOBE no longer provides support for those who don't pay to be here, they don't have a reasonably intelligent way to fix problems for non computer minded people, they want you to go through and change this setting or that (ya, I've seen the page and done the crap they tell you to do to fix the flash player so it works and... it works... for a little while then you wind up with a fkn green screen after another day or two... this is complete BS you shouldn't have to unfk things so they work every few days... you shouldn't have to deal with crap like this... I AM GOING TO USE VLC PLAYER OR SOMETHING ELSE TO TAKE CARE OF MY VIDEO PLAYER NEEDS IN MY DIFFERENT BROWSERS FROM NOW ON... YOU GUYS SUCK, YOU HAVE NO SUCH THING AS SUPPORT ANYMORE AND YOU ARE OBVIOUSLY MOVING BACK INSTEAD OF FORWARD IN THE INNOVATION DEPARTMENT!!!!)
    1.  this should be simple, install the software, install an update if the software is installed and up to date it should work... don't make me fiddle with all the extra bs, your the software developer why cant' you do that????
    2.  you tried to make it easier by making it so flash player is imbedded in my browser, congratulations you made it screwed up... think of it this way, now I have to get rid of your software to have something malleable I can deal with... your software doesn't work half the time, i'm sick and tired of dealing with it... i'm not going to deal with it anymore, I have changed the settings as directed on your help page and it worked.... for a freakin DAY, then I get green screens when I try to use it the very next day... so... I undo the changes I made the previous day... and redo the changes AGAIN and it works AGAIN.... FOR A FKN DAY!!!  WTFO!!!! this is complete and total bs, your idea to make things simpler made things more complicated, more labor intensive, and more of a pain in the azz for the rest of the world... SO I am going to find a way to not have to deal with ADOBE anymore!!! screw you adobe, screw your software, screw your lack of support.  you have nothing to offer me that I cannot get elsewhere with less drama, I hope your business crashes like your software... have a nice day!

    One of my programs needed Flash Player and downloaded it for me!  So, Problem solved.  Thanks to all who are reading this.  I would delete it if I could. 

  • Can someone suggest how to make an interactive poster?

    Hello everyone,
    Could someone suggest how to make interactive images using photoshop.  A professor of mine created a poster that had interactive graphics that made movements when rolled over as well as graphics.  If someone could suggest a tutorial it would be appreciated.  Any suggestions would be great!  Thanks!
    Sincerely,
    Jimi Ryscovyan        
    [email protected]

    Images are not interactive on their own. There has to be more then an image file created with Photoshop. I'm sure the poster image you referring to was being displayed on some electronic device of some kind which was use by some image display application like a browser, that there was some programming involved for example interactive dynamic html, mouse overs , on click perhaps some javascript or even flash. And of course an input device like a mouse for a user to use.  More then Photoshop is involved.

Maybe you are looking for

  • Scroll Bar Error!

    My younger sister logged onto Facebook, and now I can't get off! Facebook's pages are too wide for Firefox, and usually there's a horizontal scroll bar at the bottom of the screen, along with the vertical one on the right of the screen. The horizonta

  • Cancellation of GR

    Hi While cancelling GR I am getting this error mesg"Check table YEBEFU_CR: entry 10 S91978 00002 does not exist" What could be the reason. Regards, Rad

  • Only Prints Blank Pages

    I am using Acrobat 8 Professional. When I open e-mail pdf attachments I can see them, but when I try to print I simply get blank pages. The only way I seem to be able to get it to work is to uninstall/repair and then it works for a while. Any suggest

  • Error message on WebGUI

    Greetings Abapers Ive done some config for the WebGUI but i keep getting an error on the webpage. It is as follows: Details : An exception has occurred during program processing. If i click on details, i get the following: Diagnosis An exception occu

  • Apeture won't open.

    I got Aperture 3 for my MacBook Pro and it gives me an error message saying this: There was an error opening the database for the library "~/Pictures/Aperture Library.aplibrary" What do I do?