ActionScript 3.0 :: Platformer (Collision Between Player And Terrain)
Nov 6, 2010
I'm doing a project at the moment where I am creating a side scrolling platformer in AS3. Currently I have:
-The "Character' which is a ball that can be controlled using the arrow keys and has bounce, friction, gravity etc.
-A scrolling system, the character can move freely within an invisible inner boundary, once the character leaves this boundary the background will scroll to compensate.
The thing I am having issues with is creating collision detection between the "Character" and the "Background.Ground" so that the character can move along the shape of the Ground movieclip within the background movieclip.
Actionscript Code:
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.geom.Transform;
import flash.events.KeyboardEvent;
[Code] .....
View 21 Replies
Similar Posts:
Dec 15, 2002
I'm having a problem with my multiple collision detection code for a platformer game.. It checks for collisions on all objects separately and it checks only one object per frame. I need to make somekind of a loop so that it would check every object in one frame. Anyone got an idea? It's coded like this:
[Code]...
View 4 Replies
Nov 19, 2009
I have my player, I have my enemy, and I want to make it so that when I hit "A", the player attacks and if its close enough to the enemy, the enemy dies.I've found how to do this in AS2, but not AS3.
View 4 Replies
Oct 26, 2011
I have a main character in my Box2d game that has a b2PolygonShape collision. When the player crouches I am changing the body to a smaller b2PolygonShape. The logic works fine, but when I change the size (height) of the collision the character starts to fall.
Is it possible to create the new body with an offset (localPosition?) so the position of the body stays the same? This way I can play the crouch animation and change the collision without worrying that the position will change and make my sprite go bananas.
View 1 Replies
Nov 15, 2009
I'm trying to make a realistic scrolling terrain for a game I'm making. all of the movement and collision detection is 2d, but I need to make the terrain look more real.
does anyone have an algorithm for simulating a 3d terrain in 2d with the geom.Matrix class?
I know how to implement one, but I'm not sure about the logic for a transformation like this
View 0 Replies
Mar 11, 2005
How do you make destructable terrain in a game?
View 1 Replies
Dec 3, 2011
I'm trying to create simple 2D action game, something similar to well known Fancy Pants Adventures :) I've been looking for answer for more than week and all I've found is [URL] which not answers the question. (I've found also moving on platforms that are rotated but that's not I'm looking for). I have also found great (and free!) flash game engine - CitrusEngine which I'm currently using, but, it doesn't provide moving hero along curved terrain. How to make hero moving along curved terrain like this one: [URL]. There are plenty of games like this (for ex. Fancy Pants or Robot Unicorn Attack) where main character moves along the curved terrain but I can't find answer how can I do that.
View 2 Replies
Feb 28, 2006
Does anyone know how to remove parts of a shape (in a movieclip) using actionscript? Something like reverse masking (where the opaque parts hide the image) or just actually modifying the shape. I've seen it done, but I have no idea how to do it. I've tried using masks, and I saw something about masking the mask but when using setMask() you cant mask a mask. I'm looking for an effect much like the explosions in Serious Santa at NewGrounds [URL]
View 1 Replies
Jul 12, 2004
I've been trying to use ActionScript to create an isometric pseudo3d terrain generator thing, using a dot movie clip. I come from a C programming background and i thought it'd be pretty easy to just attach a load of movie clips to the stage and put them all (well references to them) into a 2d array so i could call back to them with ease for the moving and the jiggery pokery
[Code]...
View 2 Replies
Aug 13, 2009
I've created a game engine using bitmaps and box2D, the floors for the game engine is made out of a number of lines which then has a bitmap fill applied to it, then it adds a little bit of grass on top of these floors....Here's a quick video to show you what I'm talking about:http:[url].....
This all works fine on my main computer, but when I move over to my netbook, I struggle to get 10fps... Because of this I am now looking for as many ways as possible to improve the efficiency of my code. So far what I've done that appears to of had some positive effect is:
- Use bitmapCaching on layers where it's appropriate to do so.
- Use scrollRect to scroll on only the necessary part of each of the layers.
However I'm still having big problems when it comes to scrolling the terrain on my netbook - are there any ideas that anyone might have which might be able to speed up the game slightly?
View 1 Replies
Aug 21, 2010
i'm currently making a flash game which has ground and water.And its going to be big.For someone whos 13 like me i have problems.The script was edited recently so sorry to anyone who was working on it.the issues are underlined.here the script.
onClipEvent (load) {
grav = 2;
speed = 15;
[code].....
View 2 Replies
Jun 15, 2010
I have an art based platformer with a movie clip that is basically a triangle shaped object that serves as the slope.My problem is in the collision detection with the slope. Here's the code that i currently have - [code]This basically places the rectangle shape that serves as the main player (_rec) along the slope and increments its y position based on it's current x position. The reg point of the slope is on the bottom left.The problem is that this code comes into effect even if _rec is jumping over the triangle because of the square shaped hitbox of the slope. Also, for the same reason, I cannot jump while on the slope itself.I know of a way to rotate the character based on the incline in the ground but I don't really like that idea. The character should stay vertical at all times. I really don't want to do a tile based version as I have a lot of art already designed, it's only the ground objects that are basic shapes.
View 1 Replies
Apr 11, 2011
how to make coins for a platformer, the video however did not show how to keep count of the coins you collect....I've tried a million things but nothing seems to work! Here is a link to the video http:[url]....what I have to do to keep track (score) of how many coins I pick up,
View 7 Replies
Nov 3, 2011
I'm in the process of building a platformer with Flash MX using Action Script 2.0, I'm following this tutorial: [URL].. However I'm not following the tutorial, I downloaded the .fla file and followed that. The .fla file available for download functions, but my recreation does not.
I have used all the elements from the tutorial platformer, the scoring counter, the health counter, the pickups, the enemies etc. But it does not work properly.
Here is my attempt for download, can someone please explain where i've gone wrong, and if it's not too much trouble, fix it.
View 1 Replies
Nov 12, 2011
i need to make scrolling terrain but dont have how to do it for the code? What i want to do is 5 objects lets call them A,B,C,D,E scroll down the screen in random positions
View 15 Replies
Oct 16, 2009
In my file (AS2), I have a small square at the middle of the page. Diagonally to the right, I have a vertical wall which is a rectangle. Pasted inside my small square, I have the code:
onClipEvent(enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (this.hitTest(Wall._x, Wall._y, false)) _x =
[code]......
View 1 Replies
Dec 12, 2009
I want to create a platformer game, but there is no tutorials that actually tell you how.What I dont understand is:
- How the level changes when you get to a certain point
- How to do collision with walls
- How to make the player move
View 5 Replies
Jul 6, 2008
I am making my second game, and it's going to be a platformer. Unfortunately, I have no idea how to make the character (named hero) jump only to a certain height, and then fall back down. someone, please post a way to do this!
View 1 Replies
Nov 30, 2009
I'm making a simple side scrolling platform game called Kit Run. For moving left and right, I have the sprite run in place while the background scrolls in the opposite direction. However, when the sprite jumps straight up and down, the background stays stationary. What I need help with is getting the background to scroll down when the sprite moves up beyond a certain point, and up when the sprite moves down beyond a certain point. Ive tried several probably unnecessarily complicated methods that only sort of work.
View 4 Replies
Aug 10, 2010
I'm about to create a scrolling platformer game, something like Gum Drop Hop, where the background is scrolling constantly, and you have to keep running or else you'll die. Do you know any tutorials on how to do something like this? I'm not really sure how I would generate random platforms all the time...
View 5 Replies
Aug 15, 2005
I was unable to find any good tutorials or hints on terrain scrollers that isn't random.. like a huge world, and a map that points where on the map you are.
View 4 Replies
Jan 28, 2012
I am currently working on a platformer using accelerometer to move the character and xml to load levels as so..
[as]
level.x += (e.accelerationX*40);
if (e.accelerationX > 5) {
e.accelerationX = 5;
} if (e.accelerationX * 40 < 3 && e.accelerationX * 40 > -3) {
player.gotoAndStop(1);
[Code] .....
And it is all added into one movieclip called level. My problem is when the character hits under a platform it will go up it which I don't want it too, I don't know how to fix it heres the gravity code.
View 11 Replies
May 25, 2011
I'm trying to make a platformer and I'm having a problem where the character will clip half through the ground upon landing from a jump. Just so you have a clear picture -- right now all that's on the stage is the character (which the code is placed in) and the ground (a completely flat plane called 'ground')
Here's the code:
onClipEvent(load) {
jumpHeight =0;
defaultJumpSpeed = 20;
jumpSpeed = 20;
} onClipEvent(enterFrame) {
[Code] .....
Right now the character's jump constantly decreases to give the effect of gravity. It starts out positive (character moves up), then goes negative (character falls down) The character will only stop falling if they come in contact with the ground (in the form of a hit test). The problem (I think) is that the character can fall at, say, 36 pixels a second or more, so sometimes they'll be half through the ground before the hit test goes off and stops him from falling further. How do I stop it without making the character fall-rate really, really low.
View 2 Replies
Sep 14, 2009
I worked on a new Flash project, but I cant seem to find a good solution for how I want my objects to collide. In my project I have: a Ball(moving object) and a Floor(not moving).
The ball is positioned over the floor and drops onto the floor through the gravity that is applied with the code.
[Code]...
Is there a way to have a global gravity in flash AS3. In which you could choose what objects you want to be affected by it? Is there a way to have a block of code that separates moving from still objects and will not let any objects collide(not overlap)?
View 1 Replies
Sep 14, 2009
In my project I have: a Ball(moving object) and a Floor(not moving).The ball is positioned over the floor and drops onto the floor through the gravity that is applied with the code.
[code]....
First: the -23 in the code is what I don't like. Second: every single object that deals with collisions would need to be put into the if statement.Is there a way to have a global gravity in flash AS3. In which you could choose what objects you want to be affected by it?Is there a way to have a block of code that separates moving from still objects and will not let any objects collide(not overlap)?
View 2 Replies
Jan 7, 2010
What kind of code would one need to check for collisions between two symbols? I am hoping to become a game designer so this is important for future references.
View 8 Replies
Jun 21, 2010
Im currently working on a demo flash game built on AS 2.0. im a very beginner to this flash and AS and im stuck up with a very silly concept though im not able to overcome it. the problem i have is with collision detection ie hit test and im really struggling with it.
[Code]....
View 1 Replies
Jan 31, 2010
I am trying to use boxes for hit collision. I want to be precise with the collision so I was thinking about making multiple small boxes and checking for collision that way. This maybe a stupid idea or a smart one. If I do this way will that affect the performance of the game even though the boxes are invisible and wont be drawn on the stage.
map out the object starting from its center outward. Like right, left, top and bottom. I am creating a flying shooter so the plane has a long wing span. I could also map out the wing span and tail and so on.
View 2 Replies
Sep 14, 2009
In my project I have: a Ball(moving object) and a Floor(not moving).The ball is positioned over the floor and drops onto the floor through the gravity that is applied with the code.
Code:
var gy:Number = 0;
var gravity:Number = .2
function ballMovement(event:Event):void{
[code]....
First: the -23 in the code is what I don't like.
Second: every single object that deals with collisions would need to be put into the if statement.Is there a way to have a global gravity in flash AS3. In which you could choose what objects you want to be affected by it?Is there a way to have a block of code that separates moving from still objects and will not let any objects collide(not overlap)?
View 1 Replies
Feb 2, 2010
suppose I have a set of movieclips on stage. Each movieclips has its own name. I can drag one of these and check when my dragged movieclip collide with the other ones. Is there a way to determine the name of the movieclip that was hit by the dragged one without having to use a for-loop statement and/or array?
View 2 Replies