|
|
|||||
Topic, Path 4 Mouse Help | ||||||
| ||||||
You must register or log in to post a message.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. :) @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. Would it be faster to forego the loop entirely and just check for one hitTest against the parent mc? 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; } } Let's just say I'm applying this to the 'wall' MC, inside another MC: 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') The problem is, the turn around disables all the hitTests in the game, so nothing works... 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 So, can you help me please? (read below) When you change the prototype of the method hitTest for ALL movieclips with this code 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. 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"); This the the entire code on my first frame: Do you want me to email you the .fla? Judging by your last post, I guess you're meant to change: to something like But that's not working either. I should probably put the "prototype" on the second code somewhere else, but I can't see where... 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. 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?: 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); } 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: _root.follow is the head of the snake by the way... 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 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. Or could I use removeMovieclip? "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); 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'. 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... The url was from the link you just posted (http://www.bonuslevel.org/about/f8.rar)... | Flash game developmentFirst post of the topicOkay, 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! |