Be a Supporter!

I need help with my game's script.

  • 457 Views
  • 14 Replies
New Topic Respond to this Topic
uyersuyer
uyersuyer
  • Member since: May. 15, 2002
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
I need help with my game's script. 2006-11-05 13:29:38 Reply

if(Key.isDown (Key.SHIFT)) {
if(jump){
if(!_currentframe==11){
gotoAndStop(11);}}

That's supposed to make it so that whenever you press shift while jumping, it makes you go to frame 11 of the movie clip, but it doesn't work. I have no idea why.


onClipEvent (load) {
jump = false;
scream = false;
s = 6;
this.gotoAndStop(1);
b = this.getBounds(this);
_root.timerID = setInterval(_root.goTime, 10);
function move(x, y) {
h = false;
if (!_root.map.hitTest(_x+x+b.xmin, _y+y+b.ymin, true)) {
if (!_root.map.hitTest(_x+x+b.xmax, _y+y+b.ymin, true)) {
if (!_root.map.hitTest(_x+x+b.xmin, _y+y+b.ymax, true)) {
if (!_root.map.hitTest(_x+x+b.xmax, _y+y+b.ymax, true)) {
_root.map._x -= x;
_root.map._y -= y;
h = true;
}
}
}
}
return h;
}
}
onClipEvent (enterFrame) {
falling = move(0, s);
if (Key.isDown(Key.SPACE) && !falling && !jump) {
jump = true;
vel = -10;
_root.jumpSound.gotoAndPlay(2);
}
if (Key.isDown(Key.LEFT)) {
_xscale = -100;
move(-s, 0);
this.play();
_root.moveSound.gotoAndPlay(2);

}
if (Key.isDown(Key.RIGHT)) {
_xscale = 100;
move(s, 0);
this.play();
_root.moveSound.gotoAndPlay(2);

}
if(Key.isDown (Key.SHIFT)) {
if(jump){
if(!_currentframe==11){
gotoAndStop(11);}}

}
if (jump) {
if (vel<=10) {
h = move(0, vel-s);
if (h == false && vel<0) {
vel *= -1;
}
vel++;
} else {
jump = false;
}
}
if (_root.map._y<-850) {
_root.map._x = 0;
_root.map._y = 0;
scream = false;
}
if (falling) {
gotoAndStop("jump");
} else {
if (_currentframe == 5) {
gotoAndStop(1);
}
}
}
onClipEvent (keyUp) {
this.gotoAndStop(1);
}

That's the full code.

Any suggestions?


"Whoever said 'winners never quit' obviously never considered addicts." - Hoeloe

BBS Signature
ottermaniac
ottermaniac
  • Member since: Sep. 7, 2003
  • Offline.
Forum Stats
Member
Level 13
Melancholy
Response to I need help with my game's script. 2006-11-05 13:34:30 Reply

im not a pro at actionscript but i think the 'if(jump){' is wrong, maybe it should be something like

if jump = true

maybe? :P


fuck

phyconinja
phyconinja
  • Member since: Sep. 18, 2004
  • Offline.
Forum Stats
Member
Level 25
Blank Slate
Response to I need help with my game's script. 2006-11-05 13:36:21 Reply

At 11/5/06 01:34 PM, ottermaniac wrote: im not a pro at actionscript but i think the 'if(jump){' is wrong, maybe it should be something like

if jump = true

maybe? :P

actually. its the same!
if you mean
if(jump=true){

phyconinja
phyconinja
  • Member since: Sep. 18, 2004
  • Offline.
Forum Stats
Member
Level 25
Blank Slate
Response to I need help with my game's script. 2006-11-05 13:38:32 Reply

At 11/5/06 01:29 PM, uyersuyer wrote: if(Key.isDown (Key.SHIFT)) {
if(jump){
if(!_currentframe==11){
gotoAndStop(11);}}

try

if(!this._currentframe==11){
this.gotoAndStop(11);
}
}

uyersuyer
uyersuyer
  • Member since: May. 15, 2002
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to I need help with my game's script. 2006-11-05 13:56:12 Reply

None of this is working. :/


"Whoever said 'winners never quit' obviously never considered addicts." - Hoeloe

BBS Signature
Snubby
Snubby
  • Member since: Dec. 4, 2004
  • Offline.
Forum Stats
Member
Level 21
Game Developer
Response to I need help with my game's script. 2006-11-05 14:28:57 Reply

if (jump)

and

if (jump == true)

are the same thing.

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to I need help with my game's script. 2006-11-05 14:33:51 Reply

At 11/5/06 01:36 PM, phyconinja wrote: actually. its the same!
if you mean
if(jump=true){

It's not the same, actually...

if(jump = true)

Assigns the value of true to jump and returns true. You wouldn't use this in practice unless you made a typo.

if(jump)

Executes if jump is equal to or returns true; doesn't execute if jump is equal to or returns false. USE THIS

if(jump == true)

Checks the value of jump, returns true if it is true and returns false if it is false, executing accordingly. You're basically adding an unnecessary comparison when you do this, which is a waste of CPU and line space. There is no real reason to do it.


BBS Signature
KillaW0lf04
KillaW0lf04
  • Member since: Mar. 29, 2006
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to I need help with my game's script. 2006-11-05 14:37:42 Reply

Try

if(Key.isDown (Key.SHIFT)) {
if(jump){
if(_currentframe<>11){
gotoAndStop(11);}}

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to I need help with my game's script. 2006-11-05 14:39:48 Reply

At 11/5/06 02:33 PM, Paranoia wrote: if(jump = true)
if(jump == true)

Oh, to elaborate further: It's basically the difference between saying "I like cheese" and "If I like cheese then I like cheese".


BBS Signature
KillaW0lf04
KillaW0lf04
  • Member since: Mar. 29, 2006
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to I need help with my game's script. 2006-11-05 14:41:32 Reply

Sorry for the double post

but cant u also do this:

if(Key.isDown (Key.SHIFT) && jump ) {gotoAndStop(11);}

that basically makes the move go to frame 11 and stop when shift is pressed and jumping, no matter what frame the movie is currently on.

uyersuyer
uyersuyer
  • Member since: May. 15, 2002
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to I need help with my game's script. 2006-11-05 15:02:52 Reply

None of this is workinggggg.

Do I need a different script if I'm publishing in Flash 6 or something? I can't go any higher or it ruins the rest of my code.


"Whoever said 'winners never quit' obviously never considered addicts." - Hoeloe

BBS Signature
KillaW0lf04
KillaW0lf04
  • Member since: Mar. 29, 2006
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to I need help with my game's script. 2006-11-05 15:44:40 Reply

i just tried the code i gave you out and it works fine for me......

Placeable
Placeable
  • Member since: Jun. 28, 2006
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to I need help with my game's script. 2006-11-05 16:33:28 Reply

At 11/5/06 01:29 PM, uyersuyer wrote: if(Key.isDown (Key.SHIFT)) {
if(jump){
if(!_currentframe==11){
gotoAndStop(11);}}

That's supposed to make it so that whenever you press shift while jumping, it makes you go to frame 11 of the movie clip, but it doesn't work. I have no idea why.

I haven't read your whole script but if "! " is the instance name I think that's where the issues resides. You can't use that for instance names.

Basicly if you want to use _currentframe you must make it follow the object. Be it this or <instancename> or whatnot.

Try this instead:

if(Key.isDown (Key.SHIFT))
{
if(jump)
{
if(this._currentframe != 11)
{
gotoAndStop(11);
}
}

phyconinja
phyconinja
  • Member since: Sep. 18, 2004
  • Offline.
Forum Stats
Member
Level 25
Blank Slate
Response to I need help with my game's script. 2006-11-05 16:36:15 Reply

At 11/5/06 02:33 PM, Paranoia wrote: stuff

sorry.. that was just a typing error!!

TrueDarkness
TrueDarkness
  • Member since: Aug. 31, 2004
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to I need help with my game's script. 2006-11-05 16:37:30 Reply

Ah, so that's who you are. I've got this covered =D