Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-06-2010, 02:53 PM   PM User | #1
taurusrow
New to the CF scene

 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
taurusrow is an unknown quantity at this point
Inventory System

I've begun development on a isometric game, and have what I thought to be the hard part out of the way - the map generation from external files, screen-to-isometric conversions, etc. However I'm getting stumped on the "easy" stuff.

Basically what I'm trying to do is this. Create a function that will add an object to the map (stage), then add an eventlistener so when it's clicked on, it gets added to the player's inventory. Lets take this sample code:

Code:
public function addObjectToWorld(o:IsoObject):void {
   // ...code to add it to the world
  this.addEventListener(MouseEvent.CLICK, onObjectClick);
}

public function onObjectClick(e:MouseEvent):void {
  // this is where I'm having a problem....
}
In the 'onObjectClick' function, I'm trying to figure out how to add the object that's being clicked on to an array variable declared in the Main class. I had something like 'event.target.name', but that only gives me a string value of the object. I want to add the actual object to the 'playerInventory' array, so I can use them later on.

As a side note, all the objects that could be clicked on will be classes that extend 'IsoObject', so I was trying to use Polymorphism in my code (ie. all the 'playerInventory' objects were IsoObjects, so they could accept all the items such as ball(), pipe(), etc.), but it wasn't helping me come to an answer.

Any ideas?

Thanks
taurusrow is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:07 AM.


Advertisement
Log in to turn off these ads.