Be a Supporter!

Scrolling Background?

  • 251 Views
  • 13 Replies
New Topic Respond to this Topic
Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Scrolling Background? 2009-07-10 14:27:45 Reply

im making a game and at the moment im using V-Cam so the background scrolls as the player moves, but i cant figure out how to make it so the HealthBar stays on screen and the same for the Score.
so im wondering is there any other way i can make the background scroll when the player moves?
if so, can anyone link a tutorial?
(im using Flash8, AS2)

thanks!


BBS Signature
johnfn
johnfn
  • Member since: Aug. 16, 2003
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to Scrolling Background? 2009-07-10 14:33:20 Reply

Just set it relative to the position of the vcam.


[6,11,4,10,2,10,-68,5,15,-68,16,4 ,1,-68,-2,1,15,16,-67].map(function(v){ return String.fromCharCode(v + 100) }).join(""); // updated for web 2.0!

BBS Signature
MikeyTheYoshi
MikeyTheYoshi
  • Member since: Oct. 13, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Scrolling Background? 2009-07-10 14:34:00 Reply

At 7/10/09 02:27 PM, Veranan wrote: im making a game and at the moment im using V-Cam so the background scrolls as the player moves, but i cant figure out how to make it so the HealthBar stays on screen and the same for the Score.
so im wondering is there any other way i can make the background scroll when the player moves?
if so, can anyone link a tutorial?
(im using Flash8, AS2)

thanks!

Indeed there is. Do you mean like this?:
http://spamtheweb.com/ul/upload/100709/7 0432_Cool_BG_move.php

It was rushed btw.


BBS Signature
Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Scrolling Background? 2009-07-10 14:39:41 Reply

At 7/10/09 02:34 PM, MikeyTheYoshi wrote: Indeed there is. Do you mean like this?:
http://spamtheweb.com/ul/upload/100709/7 0432_Cool_BG_move.php

well, i want it so when the Player moves, it(player) stays in the middle of screen while everything else scrolls. but im having a problem doing that with V-Cam because if i put a HealthBar and i test the game the healthbar doesnt scroll with the V-Cam.
i've tried using the code

_x+=(_root.TARGET._x-_x)/1

but i cannot put this code onto dynamic text (which brings up the problem with the Score)


BBS Signature
Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Scrolling Background? 2009-07-10 14:53:30 Reply

At 7/10/09 02:33 PM, johnfn wrote: Just set it relative to the position of the vcam.

the V-Cam follows the player.


BBS Signature
headphenomenon
headphenomenon
  • Member since: May. 1, 2009
  • Offline.
Forum Stats
Member
Level 13
Programmer
Response to Scrolling Background? 2009-07-10 15:02:26 Reply

At 7/10/09 02:53 PM, Veranan wrote:
At 7/10/09 02:33 PM, johnfn wrote: Just set it relative to the position of the vcam.
the V-Cam follows the player.

There is a very easy way to do this. It involves me taking away about 5 seconds of your time. Simply take the health bar and put it inside of your v-cam. Now you have the hpBar working and scrolling with your player without it going off the screen.


06-17-11: User of the Day
07-25-11: 1500th Post
08-09-11: Level 13!

Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Scrolling Background? 2009-07-10 15:35:20 Reply

At 7/10/09 03:02 PM, U-Gamer wrote: There is a very easy way to do this. It involves me taking away about 5 seconds of your time. Simply take the health bar and put it inside of your v-cam. Now you have the hpBar working and scrolling with your player without it going off the screen.

i put the HealthBar inside the V-Cam MC and when i test it i cant see the HealthBar (i put it on a new layer inside the MC)


BBS Signature
RadMad
RadMad
  • Member since: Aug. 26, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Scrolling Background? 2009-07-10 16:39:30 Reply

try setting the health bar's movieclip to the same size as the stage, with the healthbar right where you want it on the screen. then take the script that makes the vcam follow the player and apply it to the healthbar's movieclip. this should work and can be done for everything you want to stay in one place on the screen. Preferrably, put all the movieclips, healthbar and such, in the same movieclip. makes it easier.


BBS Signature
Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Scrolling Background? 2009-07-10 17:28:08 Reply

At 7/10/09 04:39 PM, RadMad wrote: try setting the health bar's movieclip to the same size as the stage, with the healthbar right where you want it on the screen. then take the script that makes the vcam follow the player and apply it to the healthbar's movieclip. this should work and can be done for everything you want to stay in one place on the screen. Preferrably, put all the movieclips, healthbar and such, in the same movieclip. makes it easier.

ok i got that to work with the HealthBar but when i try to put the Dynamic Text (Score Counter) into a MC and put the code i used for V-Cam, the score counter doesn't seem to work (not counting).
how can i fix that?


BBS Signature
FalconPuuunch
FalconPuuunch
  • Member since: Apr. 24, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Scrolling Background? 2009-07-10 18:20:58 Reply

Here's the code to make the Vcam follow the player back and forth

onClipEvent(enterFrame){
_x+=(_root.Instancenamehere._x-_x)/2
}

And here's the code to make the Vcam follow the player in all directions

onClipEvent(enterFrame){
_x+=(_root.Instancenamehere._x-_x)/2
_y+=(_root.Instancenamehere._y-_y)/2
}

All code goes into Vcam Movieclip.


i like nachos... yea

BBS Signature
Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Scrolling Background? 2009-07-10 18:38:22 Reply

At 7/10/09 06:20 PM, FalconPuuunch wrote: Here's the code to make the Vcam follow the player back and forth

i knew this already. thanks though!
my question now is how do i make it so Dynamic Text (score counter) follows the player and still works?


BBS Signature
funkycaveman
funkycaveman
  • Member since: Jun. 10, 2008
  • Offline.
Forum Stats
Member
Level 23
Game Developer
Response to Scrolling Background? 2009-07-10 18:41:40 Reply

At 7/10/09 06:38 PM, Veranan wrote:
At 7/10/09 06:20 PM, FalconPuuunch wrote: Here's the code to make the Vcam follow the player back and forth
i knew this already. thanks though!
my question now is how do i make it so Dynamic Text (score counter) follows the player and still works?

have a varible called var score:number = 0;

and add to it when you want the score to increase.

you can make it attach to the player by converting to a movieclip and doing something like this:

scorebox.y = player.y
scorebox.x = player.x

Veranan
Veranan
  • Member since: Jun. 28, 2008
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Scrolling Background? 2009-07-10 19:31:28 Reply

At 7/10/09 06:41 PM, funkycaveman wrote: you can make it attach to the player by converting to a movieclip and doing something like this:

scorebox.y = player.y
scorebox.x = player.x

i converted the Dynamic Text to a MovieClip but now its not working.


BBS Signature
starownage3
starownage3
  • Member since: Apr. 22, 2008
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Scrolling Background? 2009-07-11 01:01:17 Reply

yopu mean something like
this._x = 0-player._x/2
dont feel like making the full script right now. -_-


My friend's sister plays wizard 101....
she's 17.....
wtf?