Be a Supporter!

Get X of Player?

  • 267 Views
  • 3 Replies
New Topic Respond to this Topic
P1raten
P1raten
  • Member since: Mar. 4, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Get X of Player? 2011-12-01 10:17:24 Reply

So, I have this ship package which controls "Player".

And I wan't to obtain this value in another file, another package, called enemy.

I.e something like

trace(Ship.x);

in the enemy package.

Any suggestions? Should I make a function in the ship package that returns x or something like that?

YoinK
YoinK
  • Member since: Jan. 5, 2001
  • Offline.
Forum Stats
Member
Level 60
Game Developer
Response to Get X of Player? 2011-12-01 11:29:20 Reply

At 12/1/11 10:17 AM, P1raten wrote: So, I have this ship package which controls "Player".

And I wan't to obtain this value in another file, another package, called enemy.

I.e something like

trace(Ship.x);

in the enemy package.

Any suggestions? Should I make a function in the ship package that returns x or something like that?

The instance name of the movieclip in which you want to know the x coordinate is Ship?
hmmm.. try

trace(Ship._x);

Kanye West Did What??????
They should make a black guy the manager, they know how to run shit!
2 Girls 1 Cup .... THE SONG!!!!

P1raten
P1raten
  • Member since: Mar. 4, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Get X of Player? 2011-12-01 11:54:31 Reply

package com.asgamer.directionalmovement 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import com.asgamer.directionalmovement.Ship;
	
	public class Enemy extends MovieClip
	{
		private var ship:Ship = new Ship();
		trace(ship._x);
	}
}

1120: Access of undefined property ship. (trace(ship._x);)

Kirk-Cocaine
Kirk-Cocaine
  • Member since: Aug. 17, 2003
  • Offline.
Forum Stats
Moderator
Level 38
Programmer
Response to Get X of Player? 2011-12-01 13:32:52 Reply

_x is AS2, x is AS3.

Enemy and Player shouldn't have references to each other. You should have a third class that acts as your game engine and have that take care of all your game logic.


The water in Majorca don't taste like what it oughta.

| AS3: Main | AS2: Main | Flash Tutorials |

BBS Signature