Play the games, create the levels

Topic, Path 4 Mouse Help

Checkout our iPhone & iPad games!

You must register or log in to post a message.

SuperMario 15 years ago
  The game got 100 levels or more. But i can't play the game. :(
Hexicube 15 years ago
  I don't think it actually has 200 levels yet, it has about 100 or something :D
SuperMario 15 years ago
  The game Path 4 Mouse is in test phase.

Sorry, this game is in test phase and it is not yet public. Try again in a few days or weeks.

The award is:

Complete 200 levels in Path 4 Mouse.
EXP +50

I like visit your game. :)
jp 15 years ago
  Yes that's right.

@gecko, make sure that you have a movieclip that contains ONLY the walls to avoid, and then you can make only one hitTest on this movieclip.
Captain_404 15 years ago
  Aren't you attaching the movie clips to one single parent movie clip?

Would it be faster to forego the loop entirely and just check for one hitTest against the parent mc?
jp 15 years ago
  You have to store all the movie clips you create into an array variable on the _root.
and onthe _root enterframe loop you do this :

for (var i:Number=levelMCs.length-1;i>=0;i--) {
if(levelMCs|i].hitTest(_root.follow._x,_root.follow._y,true)){
_root.game = false;
break;
}
}
geckojsc 15 years ago
  Now I need to change all the onClipEvent(enterFrame){s to one big onEnterFrame = function(){.

Let's just say I'm applying this to the 'wall' MC, inside another MC:
SPOILER


I want to delete that, and make one big onEnterFrame function on the _root, that does exactly the same thing to all of the 'wall' clips. (they have a linkage name of 'wallClip')
geckojsc 15 years ago
  Thanks, I'll email it to you.
The problem is, the turn around disables all the hitTests in the game, so nothing works...
jp 15 years ago
  Yes you can email the code.

The reason why the hitTest was working on your standalone version and not working in the online/embedded version, is the following :

When your swf is loaded online, its top/left corner doesn't correspond to the top/left corner of the container (the BL API swf).
So the x,y coordinates, must be translated before making the hitTest.

So when you test offline, you have to deactivate (put in comment) the protoype change, and activate it before submitting to BL.

I've never tested myself this turn around, so if ti's still doesn't work, send me the fla.

when you test your
geckojsc 15 years ago
  Ok, JP, you're logged on again.
So, can you help me please? (read below)
geckojsc 15 years ago
  Ok, I understand that it changes all the movieclips, but what does the code do to the movieclips? For me, it stops all the hitTests from working. Should I email my .fla to you?
jp 15 years ago
  Sorry that was a typo, you haev to call "_root.follow.hitTest" in your code and not "_root.follow.prototype.hitTest".

When you change the prototype of the method hitTest for ALL movieclips with this code
SPOILER

each time you will call hitTest on any MovieClip, yuo will call the method you described in the prototype.

Don't hesitate to ask if it's still not clear.
geckojsc 15 years ago
  When you said 'So, in your code, when you use "_root.follow.prototype.hitTest", you call the hitTest method you've defined in the prototype', what did you mean? Could you explain it in more detail, because I think that might be what's causing the problem...
jp 15 years ago
  I'm not sure ti's th reason but you have tp replace "_root.follow.prototype" by "MovieClip.prototype"

If it still doesn't work, create a dynamic textfield that you call "mydebugbox" and try to add traces in the prototype methid :

_root.mydebugbox.text+="hitTest obj before"+obj.x+","+obj.y+"\n");

this._parent.localToGlobal(obj);

_root.mydebugbox.text+="hitTest obj after"+obj.x+","+obj.y+"\n");
geckojsc 15 years ago
  I did everything right, using the code you gave me, but the hitTests are still off centre to the right!
This the the entire code on my first frame:
SPOILER


Do you want me to email you the .fla?
jp 15 years ago
  You don't have to change anything in your code, still call this.hitTest(.....). Send me your code by email, I will have a look.
geckojsc 15 years ago
  So I put that code on the first frame, and none of the hitTests worked.
Judging by your last post, I guess you're meant to change:
SPOILER

to something like
SPOILER


But that's not working either. I should probably put the "prototype" on the second code somewhere else, but I can't see where...
jp 15 years ago
  You have to copy paste the code onto the first frame.

With the protoype keyword, you can add, overwrite a method for ALL movieclip objects.

So, in your code, when you use "_root.follow.prototype.hitTest", you call the hitTest method you've defined in the prototype.
geckojsc 15 years ago
  Eek! Scary code!
I'll try and use it, but I don't quite understand all the "prototype", "localToGlobal" and "parent" stuff...

It should work though...
Is this right?:
SPOILER
jp 15 years ago
  gecko, you certainly fall into the problem described in the Constraints, Actionscript 2 only (Flash 8 and below)

This is the turn around :

MovieClip.prototype.oldHitTest = MovieClip.prototype.hitTest;
MovieClip.prototype.hitTest = function(x, y, sf){
var obj = {x:x, y:y};
this._parent.localToGlobal(obj);
return this.oldHitTest(obj.x, obj.y, sf);
}
geckojsc 15 years ago
  Ok...

Now for the most mysterious problem of all... The hitTest problem...

For some reason, when I upload my game to the site, the hitTests for every object are three tiles to the right, or something similar to that...

I think this might have something to do with having one swf inside another swf, in which case I don't know how we can fix it...

Here is the code I'm using for each tile:
SPOILER


_root.follow is the head of the snake by the way...
Captain_404 15 years ago
  Good to hear :)

I remember back when I first started actionscripting. It's fun to learn a whole bunch of stuff like that all at once, I kind of miss it actually :P
geckojsc 15 years ago
  Thanks Captain! I've fixed the problem of levels overlapping now! It's so wonderful to see my game coming to life! I never thought I could learn so much about actionscript in such a short time!
Captain_404 15 years ago
  If you want one thing done to multiple mc's at once, you're going to have to loop through them somehow. That doesn't have to be x's and y's, but you will have to find some method for going through them and that will probably include [string + variable] in some form or another.

And yes, you can use removeMovieClip on them. All that does is reference the object, so you can do anything to ["bob" + 3] that you could do to bob3.

Alternatively, if you don't want to have loop through them to remove them, when you attach them, you can attach them all to one mc and remove that single mc instead.

For example:

_root.createEmptyMovieClip("lvl",_root.getNextHighestDepth());
for (y=0; y<=40; y++) {
for (x=0; x<=40; x++) {
placeTile = lvl.attachMovie("tile", "tile_"+lvl.getNextHighestDepth(), lvl.getNextHighestDepth(), {_x:x*20, _y:y*20});
placeTile.gotoAndStop(map[y][x]);
}
}

Note where you need to replace _root with the mc's name.

When you want to remove the tiles, all you'd have to write is

lvl.removeMovieClip();

Of course, this means when you want a new level you'll have to recreate the lvl mc.
geckojsc 15 years ago
  But can I select all the tiles at once without the x's and y's?

Or could I use removeMovieclip?
Captain_404 15 years ago
  First, you should name your tiles something like

"tile"+x+"_"+y

This way, you'll always know the name of a tile at that position.

You can access mc's without using their actual name fairly easily, let's say you have a mc named bob3 in the root of your game, you can call bob3 by using

_root["bob"+3]._x += 5;

or even

var n = 3;
_root["bob"+n]._x += 5;

You can sue this to access all your tiles with the code

for (y=0; y<=40; y++) {
for (x=0; x<=40; x++) {
tile = _root["tile"+x+"_"+y];
tile.gotoAndStop(1);
}
}

or even just

_root["tile"+x+"_"+y].gotoAndStop(1);
geckojsc 15 years ago
  Ok...
Now I would like you to help me with this:

To attach the tiles on my map, I use the 'attachMovie' method with a movieclip linkaged 'tile'.
SPOILER


Is there a way to set all the 'tile' clips on the stage back to frame one?

I ask this so I can fix the problems of levels overlapping each other when you load a new one...
geckojsc 15 years ago
  All of them apart from MyDoNothingGameManager, which wasn't there in the first place...
jp 15 years ago
  Can you list the files you replaced (sorry for those questions but I really think the problem is not far from here)
geckojsc 15 years ago
  Well, I deleted the old files, then put the new files in the folder where all the old files were.

The url was from the link you just posted (http://www.bonuslevel.org/about/f8.rar)...

[<<] [1] [2] [3]

Flash game development

First post of the topic

geckojsc 15 years ago
  Please may I have some help with my game, Path 4 Mouse?

Okay, I would like to know how to create the level data, and load it, and make all the objects work, and a lot of other stuff too. I think I might have started too early, but I was dying to make a game for BL, and I can't really give up now!

So basically I would like to know how to make a tile based map, that opens up on the screen when you play the game, or something like that.

I might be able to manage it myself if the game was not for BL, but using the API and making arrays are two completely new things to me!
Our free flash games   Games for your site   Games for your iPhone   Contact   Twitter @jpsarda & @bonuslevelorg