How do I make a Top-down Scroller work? Specifically how do I scroll all particles at once?

19 views
Skip to first unread message

Corey

unread,
Sep 14, 2010, 10:43:49 PM9/14/10
to APE General
How do I make it so that I can scroll every particle at once?

I have a user controlled object that I want to be able to navigate
maps that I make. The maps will be bigger than whats on screen so it
means that I have to scroll the maps as the player moves. Whats the
best way to do this? The spider demo on the APE site has what I need,
but when I implement the code thats important

APEngine.container.x = -userBumper.px + halfStageWidth;

It just moves my fixed objects and not the particles that are floating
around that will make up enemies. Also, the particles don't collide
with the walls once they are moved, they only collide with the walls
initial settings. So how do I make it so that I can scroll every
particle at once?

Jake Chapa

unread,
Sep 15, 2010, 3:13:38 AM9/15/10
to ape-g...@googlegroups.com
Maybe a viewport would be a simpler change:
http://hybridmind.com/tutorials/simple-as3-viewport-tutorial/

Thanks :) Jake

> --
> You received this message because you are subscribed to the Google Groups "APE General" group.
> To post to this group, send email to ape-g...@googlegroups.com.
> To unsubscribe from this group, send email to ape-general...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ape-general?hl=en.
>

Corey

unread,
Sep 15, 2010, 7:02:44 PM9/15/10
to APE General
Ok so to combat the jumpiness I realized that I can just move
everything based on the delta position of the player controlled
object. AWESOME IDEA!

Corey

unread,
Sep 15, 2010, 5:02:39 PM9/15/10
to APE General
Ok I made my own implementation doing exactly what I said which is
moving every particle. I'm not noticing an impact on my PC but that
might be because I have a super computer :) Here is the code snippet
that I put in the key handler event

var grpGroups:Array = APEngine.groups;

//loop through our groups
for(var i:int = 0; i<grpGroups.length; i++)
{
//loop through the particles in the group
for(var l:int = 0; l<grpGroups[i].particles.length; l++)
{
grpGroups[i].particles[l].px -= _xTrans;
}
}
}

I had to change the access modifier of the groups member in the
APEngine to public to get this done. I'll probably turn it into a get
property in the future. Now the next thing that I need to work on is
getting this stuff to move fluidly instead of the jumpy movement it's
currently experiencing. I'd like to use addForce instead of modifying
px but that means that fixed particles wont move so I'm not sure what
I'll do.

I guess I'll look at the addForce code and the related code that uses
damping and implement it in my own function. I was thinking I could
also create my own particle called WallRectangle which when collided
with doesn't move but can have forces added to it. That, or set my
walls to a mas of 1,000,000,000,000 to make sure they never get moved.

On Sep 15, 3:13 am, Jake Chapa <jakech...@gmail.com> wrote:

Corey

unread,
Sep 15, 2010, 3:17:57 PM9/15/10
to APE General
Your example Fla's say unexpected file format. I'm currently trying to
understand how to get this to work.


Ok, after looking through your code I realize that each circle gets
updated every frame which is basically what I thought would have to
happen but was hoping that I could somehow avoid it. My original post
was implementing the idea of a viewport without explicitly calling it
such. I am looking for a viewport example using APE.

On Sep 15, 3:13 am, Jake Chapa <jakech...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages