Jump to content

  • Log In with Google      Sign In   
  • Create Account

AS3.0 Moving a character (listener) doesn't work


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
26 replies to this topic

#21 JETeran   Members   -  Reputation: 280

Like
0Likes
Like

Posted 30 August 2012 - 01:19 PM

Thanks Deft for your response.

What you say makes senses. In that way, I made a property for the character called currentRoom, starting at "room1" so it can have track of what room he is on.

About the container, that sounds great. If I have 3 containers, one for each room, I would have a hitTestObject with the left and right limit. If so, remove collision and addChild the second container, am I right?

I'm gonna approach it that way.

Thanks SO much guys !!

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account


Sponsor:

#22 JETeran   Members   -  Reputation: 280

Like
0Likes
Like

Posted 30 August 2012 - 03:36 PM

Hello again guys.

Ok I followed both suggestions.

I first used your code fdn2012 using other files and using my vars and stuff of course, got many errors.

Then I tried to use 3 different containers with your code and it's happened something very similiar as before.

Now I'm back at your code but with a container object pointing to an array from mission1.

So far so good, but I'm still haveing the same problem as before, room3 is not showing.

Ok but I got something: when I'm in room2 and want to go to room3, still can touch the right limit of the room1, but why if I removeChild it??

This only question is driving me CRAZY !! Each room should remove from the scene. Or is sane to remove too both left and right limit when I change rooms?

ANY suggestions will be taken as a bless !!!!

Thanks guys.

EDIT
GUYS, I did it.

I followed Deft suggestion that you have to remove the event listener if you want to really the child disappear (am I right?)

Well what I did was create 3 addEventListeners, one for each room. I know this is TOO many eventListeners, but this is the only way I was able to make it work.

What do you think??

EDIT 2
Hey guys,

Ok now I can know when the hero hitTestObject one of the objects in the rooms (WOW the code is SO long)

Ok well, I'm going to work back again the Store, because now I need to put the objects in the inventory in the objects of the room.

I'm going to try now Deft suggestion !!
http://www.gamedev.n...95#entry4974595

Thanks again Deft !!

Edited by JETerán, 30 August 2012 - 04:38 PM.

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account


#23 Deft   Members   -  Reputation: 218

Like
1Likes
Like

Posted 30 August 2012 - 05:14 PM

Always welcome Posted Image

What type of event listener you've added? You said, that you add 3 event listeners. I think, you should do that separately.

Player in first room.
Add event listener, that will test collisions for first room objects.
Player hits door to second room.
Remove event listener for first room collision testing.
Remove first room display objects from the scene.
Add all objects for second room to the scene.
Add event listener for second room collision testing.

When I say "Add event listener", I don't mean, that you should have three methods for each room. You may use only one method and store current room index, where player is at the moment. So, I can rewrite algo:


Player in first room.
Set _currentRoom variable to 1
Add event listener, that will test collisions for first room objects. Right here I'm using _collisionObjectsContainer[_currentRoom] and that's it - I've got list of first room collision objects.
Player hits door to second room.
Set _currentRoom variable to 2
Remove event listener for first room collision testing.
Remove first room display objects from the scene.
Add all objects for second room to the scene.
Add event listener for second room collision testing.

After such reimplementation you can adopt this algorithm as base for all of your game stages.

Edited by Deft, 30 August 2012 - 05:15 PM.


#24 JETeran   Members   -  Reputation: 280

Like
0Likes
Like

Posted 30 August 2012 - 08:47 PM

As always, thanks so much Deft for your cooperation.

Indeed this is the way I'm doing it :)

Ok so I have 3 ENTER_FRAMES events, one for each room. The first one detects both left and right collisions. Still inside this event, I add an If that returns me if the hero is touching the objects in that room.

So far so good, it works perfectly for the 3 rooms :D

Ok now the tricky thing, I have to make the hero be able to come back from others rooms. This is, from room 3 to room 2 and from 2 to 1.

I think that's not a problem. The thing is 2 things, one that if the hero touches the room1's left collision, it has to stop. The same for the right collision of the 3rd room. To do this, I will try to setup a flag that tells me if the hero touches it, stop movement. The thing is that it will always touch it once it touch it, you know what I mean??

Anyways I will start will all this.

Thanks so much Deft !!!

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account


#25 JETeran   Members   -  Reputation: 280

Like
0Likes
Like

Posted 30 August 2012 - 09:46 PM

I'm happy to tell you that, thanks to Deft, I'm able to move the hero freely in all the rooms Posted Image

Ok I will work now in the hero that should stop when he hits the left collision in first room and right collision in third room.

Any suggestions is welcome Posted Image

EDIT 1:
Hello again.

I'm able now to stop the hero when hits left collision of first room. I ask if hero hit tests the left invisble collision AND if the left arrow key is pressed :) Too easy.

It's buggy tho, it's making some jumps when it reaches the end. But that it's not a worry, for now.

Thanks so much Deft for all your patient !!

Let's keep up the good work.

Edited by JETerán, 31 August 2012 - 03:01 AM.

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account


#26 JETeran   Members   -  Reputation: 280

Like
0Likes
Like

Posted 03 September 2012 - 08:44 PM

Hello guys once again.

Crap I work the hell out of me and took me 2 days to settle down. I'm back with the happy announcement that I have until wenesday to finish the work.

Ok I've been working today on the hero, and so far, I was able to make it see to the left and to the right :)

Awesome, next task it's about playin the animation.

I have, from the hero's frame 2 to 9, the animation of his movements. That's great, the thing is this, when I play it's animation, the left and right limits of each room of the missions starts to bug. Sometimes touches, sometimes don't. I think it's because all the frames of the animation are not at the same length.

So I was thinking, can I make an invisible square behind all the hero's animation and stand, and make it the main activation, instead of all the hero's animation? Or somehow make the hero's stand frame make the contact?

I tried this but didn't had the results I wanted. If you have any suggestions you know is very welcome.

I'm going to keep trying tho :) Thanks so much guys !!

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account


#27 JETeran   Members   -  Reputation: 280

Like
0Likes
Like

Posted 04 September 2012 - 02:29 PM

Hello everyone :)

Ok I did it ! Create an invisible square in front of the char and works like a charm :D

Thanks so much guys, let's keep up the good work !!

Success with courage,

José Eduardo Terán

Project Management & Game Programming. DSK International Campus

Indie Game Developer
Google + Account





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS