Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-24-2009, 10:06 AM   #31
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

Quote:
Originally Posted by bluemagica View Post
yes
Really? But you have the Main class which is from an earlier example and your missing the Game class. The code seemed to work though...
aaron_da_killa is offline   Reply With Quote
Old 03-24-2009, 10:15 AM   #32
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

Flash automatically searches the root folder of the project for the classes, it will throw errors if it cant find them there, thats why its safe too include paths!

Also you need to change a your game structure to incorporate proper OOP! Don't say there isn't any way of checking collision from parent....if your stucture wont do it, then think of one that does!
bluemagica is offline   Reply With Quote
Old 03-25-2009, 05:12 AM   #33
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

Thanks, but now game dosen't have an as file =(. When I create this file called game.as:

Code:
package
{
	import flash.display.*;
	import flash.events.*;
	
	public class game extends MovieClip
	{
		public function game()
		{
		this.y = 30;
		}
	}
}
I get this error:

1046: Type was not found or was not a compile-time constant: TextField.

Anyway, I think you've taught me enough stuff now to commence work on my game, if the above question could be answerd than I defiantly can commence work on my game.

Thanks a bunch man!
aaron_da_killa is offline   Reply With Quote
Old 03-25-2009, 05:29 AM   #34
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

I have already updated the last zip, see it!
And for textfield, you need import the flash text class in game.as!
bluemagica is offline   Reply With Quote
Old 03-25-2009, 06:32 AM   #35
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Smile

Bluemagica, I love you buddy. Thanks so much for your assistance! I am very very close to getting this to work, after this problem, I can't imagine any other possible problems. I actually realized something, in my player class (which no longer relates to the document class) I was trying to add event listeners to the stage rather than "this" as I see in your example. This is probably the reason I have been having so many problems, just when I think I have it figured out, I got this runtime error I could never explain! I fixed it up and it worked perfectly!

Except one thing, now my player character doesn't respond to keyboard input. I have tested and found that these:

Code:
this.addEventListener(Event.ENTER_FRAME, moveChar);
this.addEventListener(Event.ENTER_FRAME, triggerListner);
this.addEventListener(Event.ENTER_FRAME, playerJump);
this.addEventListener(Event.ENTER_FRAME, startScroll);
work however these two do not:

Code:
this.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown);
this.addEventListener(KeyboardEvent.KEY_UP, checkKeysUp);
Any ideas?
aaron_da_killa is offline   Reply With Quote
Old 03-25-2009, 06:53 AM   #36
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

Its simple, player is a movieclip nested inside a mc on stage....and since events normally propagate in bubble manner, your player can't recieve the events!

In other words, either your player needs to have focus always(not much good), or assign the keyboard listeners to stage! This is the reason we generally create a keyboard class with listeners set to stage and use it as needed!

Oh another thing! It's a really bad practice to use multiple listeners for same event like you have done with your Enterframe......Use just one enterframe listener and call all functions from within the functions of that listener!

Code:
this.addEventListener(Event.ENTER_FRAME, eframe);
stage.addEventListener(KeyboardEvent.KEY_DOWN, chkKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, chkKeyUp);

private function eframe(e:Event)
{
   moveChar();
   triggerListener();
   playerJump();
   startScroll();
}
Also remember, if you are going to place the player by code, don't set up this listeners in the constructor, cause the stage property is available after an instance is on stage!
bluemagica is offline   Reply With Quote
Old 03-25-2009, 07:50 AM   #37
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

Alrighty, one minor problem, I can think of a work around for this but I would prefer not to use the work around. Anyway...

I have no problem calling generic movieclips from other classes, in the context of your latest example, we can easily call ttext from the ms1 class. However, what if ttext belonged to a class of its own like ms1 has its own ms class. How then do we call ttext from ms1?

Continue reading if you want an elaboration (not necessary)

See, here is my current hierarchy of movieclips:

game(player, level(all Platform instances)) - if that makes any sense

I can call level from Player (class) and Game (class) easily, however I am having difficulty calling player (movieclip) from the Platform (class) and Game (class) because player (movieclip) belongs to its own class called Player.

So how do I do this?

Thanks in advanced!
aaron_da_killa is offline   Reply With Quote
Old 03-25-2009, 08:18 AM   #38
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

parent.parent, or stage.game.player
bluemagica is offline   Reply With Quote
Old 03-25-2009, 08:30 AM   #39
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

Ah, parent.parent works fine. I did this before but obviously player musn't have been created yet or something. I had to first declare the variable and define it later on.

Thanks
aaron_da_killa is offline   Reply With Quote
Reply


Thread Tools
Display Modes 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS2] Platform game problem renegadegd Gaming and Game Development 2 12-20-2008 11:59 PM
Flash AS2 Platform game help sakit Gaming and Game Development 0 04-14-2008 03:45 PM
Platform game - not working as intended! bloodstyle Gaming and Game Development 0 03-21-2008 07:09 PM
Platform jumper - type game the_r Gaming and Game Development 5 10-08-2007 04:59 PM
help with my platform game killkenny64 Gaming and Game Development 1 10-13-2006 10:35 AM


All times are GMT. The time now is 10:10 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.