The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsAt 1/22/09 08:46 AM, micky315 wrote: onClipEvent (load) {
grav = 0;
}
onClipEvent (load) {
this._y += grav;
grav++;
}
idk whats wrong? The mc should have gravity but doesnt
okay, the only prob. i se, is that the second line of code (2nd onClipEvent) it is supposed to say:
onClipEvent(load){
grav = o;
}
onClipEvent(enterFrame){ <------------------------ you have 2 put an 'enterFrame' instead of 'load'
this._y += grav
grav++
}
eh?
onClipEvent(load){
// Initial Speed
VelX = 0 // speed that MC will move horizontally (positive = right, negative = left)
VelY = 0 // speed that MC will move vertically (positive = down, negative = up)
// Forces
Gravity = 1 // downward pull
Friction = 0.9 // rate that speed slows down
Terminal_Vel = 20 // maximum downward speed
}
onClipEvent(onEnterFrame){
// Friction - here we slow down the MCs horizontal motion and make it come to a complete stop
if(Math.abs(VelX)>=1){
VelX *= Friction
} else {
VelX = 0
}
// Gravity - here we pull the MC down until it reaches its terminal velocity
if(VelY<Terminal_Vel){
VelY += Gravity
}
// Make MC move according to speeds
this._x += VelX
this._y += VelY
}
At 1/22/09 06:55 PM, micky315 wrote: nvm still doesnt work
onClipEvent (enterFrame) {
grav = 0;
}
onClipEvent (enterFrame) {
this._y += grav;
_root.grav++;
}
Lol, you need to keep the "grav = 0" part inside the load event...
You set grav back to 0 each frame.
#include <stdio.h>
char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";
main() {printf(p,10,34,p,34,10);}
omg HAHA so funny
do this dude
onClipEvent (load) {
grav = 0;
}
onClipEvent (enterFrame) {
this._y += grav;
_root.grav++;
}
otherwise the way you have it grav is always 0
it enters the frame sets grav to adds 0 to the _y position adds 1 to grav and then goes back to setting grav to 0
awww
At 1/24/09 03:14 PM, micky315 wrote: thanks it worked and i see the problem now but how do i make this have contact with the ground mc?
You stop getting people doing your coding and look at tutorials!
You could also write a function.
Example:
Main Timeline
function makeGravGoNow() {
if(grav < maxGrav) {
grav ++
} else if(grav >= maxGrav) {
grav = maxGrav;
}
player._y += grav;
}
Player Code
onClipEvent(load) {
grav = 0;
maxGrav = 12;
}
onClipEvent(enterFrame) {
if(this.hitTest(_root.ground)) {
grav = 0;
} else if(!this.hitTest(_root.ground)) {
makeGravGoNow();
}
}
Thats just a example, ud change it around to meet your needs. BTW, player is the instance name of the mc your targeting.
i got a code from a ut but it still aint workin
onClipEvent (load) {
grav = 0;
}
onClipEvent (enterFrame) {
grav++;
this._y += grav;
}
onClipEvent (load) {
if (level.hitTest(_x=(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
if (level.hitTest(_x=(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (level.hitTest(_x, _y-(_height), true)) {
grav = 3;
}
}
...
Remember that when you use a clip event handler, when set to load it's only going to run once when the mc is loaded onto the stage. If you use the enterframe condition, then it's going to run every frame so long as the mc is on the stage. What this means is, if you want to check something every frame, you need to use enterFrame. In this case you want to check to see if the clip is touching the ground, you would use enterFrame. If you're loading the grav variable, you'll load it in the load condition because you only need to load it once. See what I mean?
Maybe you should deal with something simpler, you're obviously in over you head. Better to build up your skills before approaching this problem.
#include <stdio.h>
char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";
main() {printf(p,10,34,p,34,10);}
At 1/26/09 08:10 PM, micky315 wrote: its just a simple code to stop gravity, i understand it but its not working
If it's so simple, why can't you get it to work? Don't underestimate Actionscript. Just because you think it's simple doesn't make it so, especially if you don't know what you're talking about. Go back to some other tutorials and start from there. Try using AS: Main, there's at least 10 different tutorials on platforming and making games.