|
-
...dishing dimes on an .fla!
[disc / help] best way to do a scrolling background and centered hero...
I've searched through various tutes on here, and other sites.
I know how to make a background scroll, but wondered what your best / most efficient way of creating one is...?
briefly, I'm using thiscode:
bgd._y - vy;
where vy velocity of the backround scroll...
I know its not much harder than that really, but what's the best way to keep your hero centered as well, without lumping your hero and background in one 'world' clip?
-
Style Through Simplicity
Well there are a few methods of scrolling:
1) You can just do what your doing. Scroll the whole background in the opposit direction to the direction you want the character to appear to move in.
2) You can use a gotoAndStop engine if your game is tile based, however this can be quite cpu intensive and perhaps a little tricky to set up
3) Use bitmap data with flash 8. What I like to do is build one big bitmap out of a tile set bitmap, and then just display the part that the player is currently on. Of course you don’t have to use tiles, you can do the same thing with a pre made bitmap image. I think this is probably the fastest method although I could be wrong (I’ve never done any tests)
I'm not sure what you mean about keeping the character centred... if you don't move the character then he is always going to be in the centre.
Ali
-
...dishing dimes on an .fla!
 Originally Posted by alillm
Well there are a few methods of scrolling:
1) You can just do what your doing. Scroll the whole background in the opposit direction to the direction you want the character to appear to move in.
I'm not sure what you mean about keeping the character centred... if you don't move the character then he is always going to be in the centre.
Ali
Think I'm gonna stick with the method I'm using...
...I was actually being stupid and trying to move both the character and the background at the same time, but realised I don't need too!
-
M.D.
whats wrong with the world setup. It makes the most sense and is the easiest to use. When every thing shares the same coordinate space headaches are minimum
-
Truimagz.com
yes, it does help when you start trying to do things like have enemies chase you, if your player is not inside the world, I bet your enemies are, and then your x/y is on a different plane than theres, among other problems soon to come.
-
...dishing dimes on an .fla!
Here's my basic engine so far...
http://www.rocketchicken.flashwizard...ot engine.html
basically at the moment I have my "world" Mc, with a "bgd" clip nested inside it, along with my "hero" clip.
I had a previous version of this engine with just a huge great lonnnnnggg bgd tile / image. However I would like to be able to attach random tiles to the right of the bgd tile as the bgd scrolls along. Random tiles being so that the game isn't the same each time you play it.
How do you add tiles to the right of your bgd, within your world MC, as the game scrolls along?
I was reading up on tonypa's tutes but got confused half way through and am now stuck in a rut.
-
...dishing dimes on an .fla!
you will have to ignore the fact that if you fire at full power the background image will be lost on the way up and down....wait until the power is at least half way gone before firing...
-
...dishing dimes on an .fla!
*bump!
-
...dishing dimes on an .fla!
*bump! 
any help would be appreciated...
cheers...
Jeff
-
Truimagz.com
are you looking for a scrolling background engine with a centered hero>?
http://www.truimagz.com/forum/viewtopic.php?t=18
I posted this tut in a thread, but maybie you missed it, or maybie it didnt help, I dont know the ansewr to either, so Im offering.
-
...dishing dimes on an .fla!
Hi...
not exactly...I've moved on from centering the hero, just didn't want to create a new thread for my question...I've got my engine working...
http://www.rocketchicken.flashwizard...hotengine.html
I just want to be able to add random MC's to the right hand side of the bgd as it scrolls along...
I thought the way to do it was by using tiles, but I maybe wrong???
-
M.D.
link didn't work. But...
if your world simply moves on the x axis:
var depth = world.getNextHighestDepth()
var enemy = world.attachMovie("enemy", "enemy"+depth, depth)
enemy._x = -world._x + Stage.width + enemyWidth / 2;
enemy._y = Stage.height;
-
...dishing dimes on an .fla!
the link works...just tried it again...
-
...dishing dimes on an .fla!
this is the code I'm using to attach my tile as the world moves off the stage...
code:
//check to see if background is off screen, if yes, add new tiles...
//-----------
if(world.bgd._x >= -686){
world.bgd.attachMovie ("tile", "tile", world.bgd.getNextHighestDepth(),{_x:world._x + Stage.width, _y:Stage.height});
}
//-----------
however, as you can see if you play the game, (please release the character at half power), the tile doesn't attach itself in the right sort of position. I know it's something to do with the registration point of the tile perhaps?...you can see the green tile is not being attached on the stage correctly.
...can anyone help?
Last edited by pointguard; 02-19-2007 at 09:53 AM.
-
...dishing dimes on an .fla!
having a real trouble to get this thing sorted...
code:
//check to see if background is off screen, if yes, add new tiles...
//-----------
if(world.bgd._x >= -686){
world.bgd.attachMovie ("tile3", "tile3", world.bgd.getNextHighestDepth(),{_x:world._width-1, _y:Stage.height});
}
//-----------
please help or let me know where I'm going wrong...pulling my hair out trying to get it done...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|