Code Error

Posted by DSDownload on May 7, 2008, 7:01 p.m.

Ok, so I was experimenting with a sword slasher game, and I have this problem. The code is fine, but nothing happens.

Here it is:

—–

Key Press 'X'

—–

if image_index = 0

instance_create(x,y,obj_blockmask) with sprite_index = spr_blockmaskup

hspeed = 0;

if image_index = 1

instance_create(x,y,obj_blockmask) with sprite_index = spr_blockmaskdown

hspeed = 0;

if image_index = 2

instance_create(x,y,obj_blockmask) with sprite_index = spr_blockmaskleft

hspeed = 0;

if image_index = 3

instance_create(x,y,obj_blockmask) with sprite_index = spr_blockmaskright

hspeed = 0;

—–

And basically whats supposed to happen, is, if the image index = 0, which is the guy facing up, it'll instance create obj_block mask, which is used to test if the enemy is in collision with the sword, and if it will receive damage. The sprite_index is just what it is, the sprite, hspeed so the character doesnt move while blocking.

If you could please help me fix this thatd be great.

-DSDownload

—–

Not all sayings are worth listening to

P.S. (I didnt want to triple post) I fixed everything, thanks kenon

Comments

Kenon 16 years, 6 months ago

ok. your problems are the with codes.

try this.

Quote: Code I made up on the spot

var tmp;

tmp=instance_create(x,y,obj_blockmask);

switch (image_index)

{case 0: tmp.sprite_index=spr_blockmaskup;break;

case 1: tmp.sprite_index=spr_blockmaskdown;break;

case 2: tmp.sprite_index=spr_blockmaskleft;break;

case 3: tmp.sprite_index=spr_blockmaskright;break;}

hspeed=0;

Cesar 16 years, 6 months ago

why do you come here? O_o

Josea 16 years, 6 months ago

Kenon's code is 100% correct.

Kenon 16 years, 6 months ago

@Rawrspoon: Some of us know what we're talking about with GM :D

DSDownload 16 years, 6 months ago

works fine, but the mask isnt where its supposed to be. I made them so if i overlapped them they would be in the correct position. But now theyre a little but to the bottom right.

rawr what do you mean?

DSDownload 16 years, 6 months ago

Sorry for double posting, i see no edit button, but another problem is, i need it so if i hold X, it will stay, if i press/hold, it will just do all its sub images(1) and then disappear again

Cesar 16 years, 6 months ago

I mean that asking us is like asking a bear for honey.

it's stupid

DSDownload 16 years, 6 months ago

So your saying i dont need to be polite and ask? Just say, give me the code for this?

DSDownload 16 years, 6 months ago

ANOTHER double post, (if anyone knows how to edit a post could you tell me?)

Ok, I fixed the positioning, but now the problem is, I need it to stay for however long I hold the button

Alert Games 16 years, 6 months ago

no he's saying dont ask at all.

you already posted it on the gmc anyway