Be a Supporter!

Best way to Scroll?

  • 529 Views
  • 18 Replies
New Topic Respond to this Topic
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Best way to Scroll? 2010-03-31 16:21:26 Reply

Basically the way i am doing it at the moment the charachter remains in a stationary point on the stage, and any velocities/gravity originally used to move him is now used to move the stage in the opposite direction.

This works, however when i want to have another movieclip attach to this by saying

addonmc.y = ground.y+amount

It doesn't actually follow it, it seems to slide about.(watch the camel when you jump) Anyway, i really need help now i've been trying various things for days and i've got nothing.

Please help :(


BBS Signature
Innermike
Innermike
  • Member since: Sep. 11, 2009
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Best way to Scroll? 2010-03-31 17:36:37 Reply

Besy way to scroll

have the code you had before to move the char ,additionally just do this on the root timeline (or doc clas)

x = (Char.x-300)*-1 // ditto for y axis and 300 in place of half whatever your stage height is, it will be a bit rigid so i suggest you ease it


nobody

CrustySheet
CrustySheet
  • Member since: May. 3, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Best way to Scroll? 2010-03-31 22:16:49 Reply

i don't like that method :P

if you go right to where the slope is and dont jump you lose your character

scuddle666
scuddle666
  • Member since: Dec. 25, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Best way to Scroll? 2010-03-31 22:32:30 Reply

Use vcam. have it set to the players._x; and ._x; position, Then it will fallow the player, you can have enemies or anything else, but the screen will still scroll with the player.

AdmittingZero
AdmittingZero
  • Member since: Mar. 21, 2010
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Best way to Scroll? 2010-03-31 22:51:02 Reply

I always have a problem when I use the VCam in my games, my HUD shakes when the camera moves.


MSN/Email-> kevin.stubbs@live.com -Need artists!
The 9th Legion
(Looking for somebody to create the site for $$$).

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to Best way to Scroll? 2010-04-01 12:39:30 Reply

I hate vcam, but i can give it a try i suppose. Is there an as3 version?

Does anyone have any betters soloutions?


BBS Signature
Mufanza
Mufanza
  • Member since: Aug. 22, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Best way to Scroll? 2010-04-01 12:54:58 Reply

Nah, I don't think VCam is a good idea that much.
I've been solving this some time ago. If those other movie clips besides your character are enemies or something like that, you can try creating them in the same Movie Clip as the ground is (i.e. ground will be their parent). Therefore, you can move them normally, since the ground is moving with them.
Thats how I solved it anyway.

CompleteDouche
CompleteDouche
  • Member since: Dec. 1, 2008
  • Offline.
Forum Stats
Member
Level 09
Musician
Response to Best way to Scroll? 2010-04-01 12:56:54 Reply

At 4/1/10 12:39 PM, Depredation wrote: Does anyone have any betters solutions?

Its one of the dumbest things to do when making a game.
The as3 version isn't as bad, but is still horrible practice, and can even slow down the game when many things are happening.
Other than that, HDXMike's way is still a solid way of doing it.


No matter what your weaknesses are, make sure your own abilities supersede them.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to Best way to Scroll? 2010-04-01 13:12:02 Reply

Yeah HDXMike seems to be on the right track so thanks for that. Here's what happens when i use that technique however. It Bounces :(

var p:MovieClip = MovieClip($e.target);
			p.vx = p.spd*(keys[39]-keys[37]);
			p.x += p.vx;
			
			p.grav++;	
			p.y += p.grav;
			
			MovieClip(root).x = (p.x-stage.stageWidth/2)*-1;
			MovieClip(root).y = (p.y-stage.stageHeight/2)*-1;
			
			for each(var u in hArray) {	
			
				while(u.hitTestPoint(p.x-15, p.y, true) || u.hitTestPoint(p.x+15, p.y, true)) {
					p.y--;
					p.grav = 0;
					p.jmp = false;
				}
				
				if(HitTest.complexHitTestObject(u, hbox, 3)) {
					p.x -= p.vx;
				}
				
				/*if(HitTest.complexHitTestObject(u, tbox, 3) && p.jmp) {
					p.y -= p.grav-1;
					p.grav = 0;
				}*/
				
			}

That's the code, any help?


BBS Signature
rednekSVK
rednekSVK
  • Member since: Apr. 20, 2007
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Best way to Scroll? 2010-04-01 13:18:21 Reply

My post has been ignored :C

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to Best way to Scroll? 2010-04-01 14:24:48 Reply

Please help :( This is really killing me.


BBS Signature
Innermike
Innermike
  • Member since: Sep. 11, 2009
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Best way to Scroll? 2010-04-01 15:29:19 Reply

At 4/1/10 02:24 PM, Depredation wrote: Please help :( This is really killing me.%u2248%u2248%u2248

God , i SAID it would be rigid , and jumpy which is why i suggested you ease it jesus

example code

RX= (Mike.x-350) *-1;
        RY= (Mike.y-270) *-1;
	
	x+=(RX-x)/5;
	y+=(RY-y)/30

nobody

CaptainPoncho
CaptainPoncho
  • Member since: Nov. 29, 2003
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Best way to Scroll? 2010-04-01 15:35:35 Reply

What you're doing:

- Moving the player and then checking if the player is hitting the ground. If he is, you shoot him up x pixels.

What you should be doing:

- Checking if the character will be hitting the ground when he moves. If he does, you don't move him.


BBS Signature
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to Best way to Scroll? 2010-04-01 17:07:49 Reply

At 4/1/10 03:29 PM, HDXmike wrote: God , i SAID it would be rigid , and jumpy which is why i suggested you ease it jesus

I did ease, it just wasn't by enough, i'm not an idiot, i just can be stupid with code when it's frustrating me.

Thanks all, especially HDXmike.

At 4/1/10 03:35 PM, CaptainPoncho wrote: - Checking if the character will be hitting the ground when he moves. If he does, you don't move him.%u2248%u2248%u2248

Out of interest, how would you suggest doing that?


BBS Signature
Mufanza
Mufanza
  • Member since: Aug. 22, 2009
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Best way to Scroll? 2010-04-01 18:16:04 Reply

Have you considered what I've said?

Innermike
Innermike
  • Member since: Sep. 11, 2009
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Best way to Scroll? 2010-04-01 21:27:07 Reply

At 4/1/10 06:16 PM, Mufanza wrote: Have you considered what I've said?%u2248%u2248%u2248

there is 0 point in your suggestion , mine has the same effect without all that nested MC crap . you can manipulate stage properties like that you know


nobody

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to Best way to Scroll? 2010-04-02 12:43:31 Reply

At 4/1/10 09:27 PM, HDXmike wrote: there is 0 point in your suggestion , mine has the same effect without all that nested MC crap . you can manipulate stage properties like that you know

Yeah i want to keep this clean and precise, HDX's way allows me to do that. Thanks a lot for the suggestion, i'll credit you. I knew you could just move the stage and i'd already done that, however i was adding onto it's current position rather than just setting it in relation to the players value.

Thanks again Mike.


BBS Signature
Innermike
Innermike
  • Member since: Sep. 11, 2009
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Best way to Scroll? 2010-04-02 12:54:59 Reply

At 4/2/10 12:43 PM, Depredation wrote: Thanks again Mike.

Your welcome :3


nobody

4urentertainment
4urentertainment
  • Member since: Aug. 1, 2008
  • Offline.
Forum Stats
Moderator
Level 13
Game Developer
Response to Best way to Scroll? 2010-04-02 13:35:10 Reply

At 4/1/10 05:07 PM, Depredation wrote:
At 4/1/10 03:35 PM, CaptainPoncho wrote: - Checking if the character will be hitting the ground when he moves. If he does, you don't move him.%u2248%u2248%u2248
Out of interest, how would you suggest doing that?

If I understood him correctly, then before checking if the correct key is down then moving the player, you check if the player is hitting the ground, only if he's not hitting will he move.

That, or you can do it the way box2D does it, that's to calculate where the object will be in the next frame, if it will be hitting something, then it reacts accordingly, but that's only for fast moving objects that could go through walls.

Mike's solution seems to suffice though.