00:00
00:00
View Profile Pixellator
This is an abandoned account

Male

---

---

---

Joined on 12/6/07

Level:
5
Exp Points:
260 / 280
Exp Rank:
> 100,000
Vote Power:
4.45 votes
Rank:
Civilian
Global Rank:
> 100,000
Blams:
0
Saves:
10
B/P Bonus:
0%
Whistle:
Garbage

Titan210 platformer instructions

Posted by Pixellator - June 1st, 2008


For titan210:

Now a couple things you may want to think about is #1: The ground! Have you made it a movie clip? Name it ground, because you must. Also, you must give it the instance name of ground. If that doesn't work, than put this ActionScript code on the player. But not in it, just click on the movie clip and right click and choose Actions and enter this code in the box that pops up:

onClipEvent (load) {
var grav:Number = 0;
// gravity
var speed:Number = 10;
// how fast you walk
var jumpHeight:Number = 15;
// how high you jump
var slow:Number = .7;
// sets water falling speed
var slowspd:Number = speed/1.5;
// sets water walking speed
var setspeed:Number = speed;
var scale:Number = _xscale;
var ex:Number = 5;
// makes hitTests better, change for a closer hitTest (warning, more buggy if smalle, less real if further)
this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
if (_root.water.hitTest(_x, _y, true)) {
if (grav>0) {
grav *= slow;
}
speed = slowspd;
} else {
speed = setspeed;
}
if (Key.isDown(68)) {
_x += speed;
_xscale = scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else if (Key.isDown(65)) {
_x -= speed;
_xscale = -scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79) && !Key.isDown(73)) {
this.gotoAndStop(3);
}
}
if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68) && !Key.isDown(73)) {
this.gotoAndStop(5);
}
if (Key.isDown(73) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68) && !Key.isDown(79)) {
this.gotoAndStop(4);
}
if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
this.gotoAndStop(2);
}
if (_root.ground.hitTest(_x+(_width/2)+ex , _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex , _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
}

That code is completely errorless so if anything goes wrong we will at least know it is not the ground's or the player's fault. Please comment back if things on the ground still have no function. :D

Also, did you make the registration point on the player at the bottom center? If it is anywhere else, some parts of the player may fall through the ground, while the registration is the solid part :o

Okay, now continuing onto you little V-Cam there. Here is what you do. Make a rectangle as wide and tall as the screen. If you are using the basic screen, it should be 550 pixels wide, 400 tall. select the entire rectangle and for the Width and Height (Example in image below) put the numbers in their correct spots. Also, on the first frame inside the V-Cam movie clip, put this code:

parentColor.setTransform(camColor.getT ransform());
function camControl() {
parentColor.setTransform(camColor.getT ransform());
var scaleX = sX/this._width;
var scaleY = sY/this._height;
_parent._x = cX-(this._x*scaleX);
_parent._y = cY-(this._y*scaleY);
_parent._xscale = 100*scaleX;
_parent._yscale = 100*scaleY;
}
function resetStage() {
var resetTrans = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};
parentColor.setTransform(resetTrans);
_parent._xscale = 100;
_parent._yscale = 100;
_parent._x = 0;
_parent._y = 0;
}
// make frame invisible
this._visible = false;
// Capture stage parameters
var oldMode = Stage.scaleMode;
Stage.scaleMode = "exactFit";
var cX = Stage.width/2;
var cY = Stage.height/2;
var sX = Stage.width;
var sY = Stage.height;
Stage.scaleMode = oldMode;
// create color instances for color
// transforms (if any).
var camColor = new Color(this);
var parentColor = new Color(_parent);
// Make the stage move so that the
// v-cam is centered on the
// viewport every frame
this.onEnterFrame = camControl;
// Make an explicit call to the camControl
// function to make sure it also runs on the
// first frame.
camControl();
// If the v-cam is ever removed (unloaded)
// the stage, return the stage to the default
// settings.
this.onUnload = resetStage;

Also, make sure that the registration point of the V-Cam is in the direct center!! Okay, now go out of the V-Cam. Your V-Cam is now good to go. But, you should have made a layer for the V-Cam. Yes, there is a layer for the main game content, and then the layer for V-Cam and V-Cam only. Make the layer for V-Cam over the main game content layer. Example below in the image. Comment if you still have any questions, titan210.

Titan210 platformer instructions


Comments

hi he doesn't sink through the ground now, the registration point was in the middle of him XD

but the v-cam still doesn't work :S

this is the error that came up:

**Error** Symbol=V-cam, layer=Layer 1, frame=1:Line 1: ')' or ',' expected
parentColor.setTransform(camColor.get T ransform());

Total ActionScript Errors: 1 Reported Errors: 1

I can't see what the problem might be, I will look into it and respond when I figure it out.

Computer talk make me brain go fizzle out

make me feel dumdum

I oost you after the word "For".

I meant to say lost, not oost.