Be a Supporter!

Issue regarding coding

  • 367 Views
  • 5 Replies
New Topic Respond to this Topic
Pork
Pork
  • Member since: Sep. 25, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Issue regarding coding 2010-07-17 10:00:01 Reply

I've come across a problem whilst developing my new game. For some reason I can't get the bullets to interact with the enemy on the stage. Basically I want the enemy movieclip to play the next frame upon hitting in the bullet movieclip which is shot from the player. I cant think what's wrong in my coding or whether it is an issue with instance names.

Here is a link to the .fla I am using if anyone has the time to have a look and let me know what I need to change in order for it to work.

Arrow keys to move the red square and spacebar to shoot. The enemy is the black box.


BBS Signature
kylelyk
kylelyk
  • Member since: May. 15, 2008
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Issue regarding coding 2010-07-17 11:16:05 Reply

Use SpamTheWeb to post Flash Files. Its ad-free and easier for people like me to figure out which download button is the right one. Plus no sign-up required.


Kylelyk: Forwards and Backwards, Over and Out.

BBS Signature
PoppyClock
PoppyClock
  • Member since: Aug. 19, 2006
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Issue regarding coding 2010-07-17 11:17:15 Reply

At 7/17/10 11:16 AM, kylelyk wrote: Use SpamTheWeb to post Flash Files. Its ad-free and easier for people like me to figure out which download button is the right one. Plus no sign-up required.

Why not use your newgrounds dump?


Balderdash and PoppyClock

BBS Signature
Pork
Pork
  • Member since: Sep. 25, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to Issue regarding coding 2010-07-17 11:18:47 Reply

At 7/17/10 11:16 AM, kylelyk wrote: Use SpamTheWeb to post Flash Files. Its ad-free and easier for people like me to figure out which download button is the right one. Plus no sign-up required.

Thanks! Much better link here :)


BBS Signature
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Issue regarding coding 2010-07-17 20:02:55 Reply

At 7/17/10 11:18 AM, Pork wrote:
At 7/17/10 11:16 AM, kylelyk wrote: Use SpamTheWeb to post Flash Files. Its ad-free and easier for people like me to figure out which download button is the right one. Plus no sign-up required.
Thanks! Much better link here :)

Bah, gotta use cs5 for this one. >.<

So first of all it looks like you have:

onClipEvent(load){
if (this.hitTest(_root.bullet[i]))
	{
		this.gotoAndStop(2);
	}
}

1. This is a load event. It's only checking for collision. Put it at enterframe
2. What is this "i" variable it's never defined or set. Use a loop.

Was going to post a fix example but then I saw:

this._y -= bulletspeed;
				if (this._y < -1 * this._height) {
					this.removeMovieClip();
				}

On you player. -_-

Meaning that your obviously copy/pasting this, and doing it incorrectly at that. Go out and lean this stuff or you'll never be any good.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
Pork
Pork
  • Member since: Sep. 25, 2004
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to Issue regarding coding 2010-07-28 11:24:03 Reply

Ok then I've made some changes to the coding... I still can't figure out how to get the enemy to interact with the bullets.

Instead of creating random numbers for the bullets I've done the obvious thing and included "i++" which just increases every time. I assumed I could use the same piece of coding that created the bullet to destroy the enemy. Hmmm

>> Here is the .fla <<


BBS Signature