Skocz do zawartości

Rekomendowane odpowiedzi

Opublikowano

Mam pewien problem z którym nie mogę sobie poradzić. Szukałem rozwiązania w poradnikach i innych tematach ale żaden nie pomógł.

Robię grę dla dwóch graczy i kiedy uderzę w postać to wyskakuje taki error:

FATAL ERROR in

action number 1

of Step Eventshurik

for object naruto:

 

Push :: Execution Error - Variable Get -1.hp(100004, -2147483648)

at gml_Object_naruto_CollisionEvent_1 (line 1) - hp-=10;

 

W create u pierwszego gracza mam takie coś:

GML
hp = 100;

W kolizji z uderzeniem:

GML
hp -= 10;

 

if (hp<=0)

instance_destroy();

U drugiego gracza mam tak samo tylko że hp2.

Z tego co zauważyłem to jest coś nie tak z zabieraniem hp.

Opublikowano

-1.hp(100004, -2147483648)

 

Głupie pytanie z mojej strony, ale wie ktoś co oznacza ta druga liczba w kodzie błędu? Nigdy nie zwracałem na to uwagi.

Może to da jakąś wskazówkę jak to naprawić?

Opublikowano

Nic nie dało. Teraz jak oberwie jest takie coś:

 

FATAL ERROR in

action number 1

of Step Eventshurik

for object naruto:

 

Push :: Execution Error - Variable Get -1.hp(100004, -2147483648)

at gml_Object_naruto_CollisionEvent_1 (line 3) - hp -= 10;

Opublikowano

Jaki jest cel dawania tam hp2, jeśli to zmienna lokalna, a nie globalna. Zmień to, może zrobiłeś gdzieś błąd i zamiast hp2 dałeś hp. I czy na pewno masz zadeklarowaną (tak się to nazywało?) zmienną, przed zabraniem hp.

Opublikowano

informacje:

 

Player 1:

 

Information about object: naruto

Sprite: narutostoi

Solid: false

Visible: true

Depth: 0

Persistent: false

Parent:

Mask:

 

No Physics Object

Create Event:

 

set variable facing to 0

execute code:

 

hp = 100;

 

Step Event:

 

if relative position (0,1) is collision free for Only solid objects

set the gravity to 0.5 in direction 270

else

set the gravity to 0 in direction 270

if vspeed is equal to 12

set variable vspeed to 12

Collision Event with object wallik:

 

set the vertical speed to 0

Collision Event with object invwall:

 

set the vertical speed to 0

Collision Event with object shurik:

 

execute code:

 

with (other)

{

hp -= 10;

if (hp<=0) instance_destroy();

}

 

Key Press Event for Key:

 

start moving in directions 000100000 with speed set to 10

set the sprite to narutobieg with subimage 0 and speed 1

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and mirror horizontally

set variable facing to 180

Key Press Event for Key:

 

if relative position (0,1) gives a collision with Only solid objects

set the vertical speed to -12

set the sprite to sprite4 with subimage 0 and speed 0.9

Key Press Event for Key:

 

start moving in directions 000001000 with speed set to 10

set the sprite to narutobieg with subimage 0 and speed 1

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and no mirroring

set variable facing to 0

Key Press Event for Key:

 

set the sprite to narutolad with subimage 0 and speed 1

Key Press Event for Keypad 0 Key:

 

change the instance into object kyuubi, not performing events

Key Press Event for Keypad 2 Key:

 

set the sprite to narutothrow with subimage 0 and speed 1

create instance of object shurik2 at relative position (0,0) with speed 12 in direction facing

Key Release Event for Key:

 

start moving in directions 000010000 with speed set to 0

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and no mirroring

set the sprite to narutostoi with subimage 0 and speed 1

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and mirror horizontally

Key Release Event for Key:

 

start moving in directions 000010000 with speed set to 0

set the sprite to narutostoi with subimage 0 and speed 1

Key Release Event for Key:

 

set the sprite to narutostoi with subimage 0 and speed 1

Key Release Event for Keypad 1 Key:

 

set the sprite to narutostoi with subimage 0 and speed 1

Key Release Event for Keypad 2 Key:

 

set the sprite to narutostoi with subimage 0 and speed 1

 

 

 

Player2:

Information about object: sasuke2p

Sprite: sasukestoi

Solid: false

Visible: true

Depth: 0

Persistent: false

Parent:

Mask:

 

No Physics Object

Create Event:

 

execute code:

 

hp2 = 100;

 

Step Event:

 

if relative position (0,1) is collision free for Only solid objects

set the gravity to 0.5 in direction 270

else

set the gravity to 0 in direction 270

if vspeed is equal to 12

set variable vspeed to 12

Collision Event with object wallik:

 

set the vertical speed to 0

Collision Event with object invwall:

 

set the vertical speed to 0

Collision Event with object shurik2:

 

execute code:

 

with (other)

{

hp2 -= 10;

if (hp<=0) instance_destroy();

}

 

Key Press Event for A-key Key:

 

start moving in directions 000100000 with speed set to 11

set the sprite to sasukebieg with subimage 0 and speed 1

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and mirror horizontally

set variable facing to 180

Key Press Event for D-key Key:

 

start moving in directions 000001000 with speed set to 11

set the sprite to sasukebieg with subimage 0 and speed 1

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and no mirroring

set variable facing to 0

Key Press Event for F-key Key:

 

if facing is equal to 180

set the sprite to sasukecombo1 with subimage 0 and speed 0.4

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and mirror horizontally

if facing is equal to 0

set the sprite to sasukecombo1 with subimage 0 and speed 0.4

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and no mirroring

Key Press Event for G-key Key:

 

set the sprite to sasukethrow with subimage 0 and speed 1

create instance of object shurik at relative position (0,0) with speed 12 in direction facing

Key Press Event for H-key Key:

 

if facing is equal to 180

set the sprite to sasukecombo2 with subimage 0 and speed 0.2

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and mirror horizontally

if facing is equal to 0

set the sprite to sasukecombo2 with subimage 0 and speed 0.2

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and no mirroring

Key Press Event for W-key Key:

 

if relative position (0,1) gives a collision with Only solid objects

set the vertical speed to -12

set the sprite to sasukeskok with subimage 0 and speed 0.5

Key Release Event for A-key Key:

 

start moving in directions 000010000 with speed set to 0

set the sprite to sasukestoi with subimage 0 and speed 1

scale the sprite with 1 in the xdir, 1 in the ydir, rotate over 0, and mirror horizontally

Key Release Event for D-key Key:

 

start moving in directions 000001000 with speed set to 0

set the sprite to sasukestoi with subimage 0 and speed 1

Key Release Event for F-key Key:

 

set the sprite to sasukestoi with subimage 0 and speed 1

Key Release Event for G-key Key:

 

set the sprite to sasukestoi with subimage 0 and speed 1

Key Release Event for H-key Key:

 

set the sprite to sasukestoi with subimage 0 and speed 1

Opublikowano

Aha trochę nie zrozumiałem co chciałeś osiągnąć, myślałem że to gracz bezpośrednio uderza drugiego gracza a nie poprzez jakiś dodatkowy obiekt.

 

Więc tak w obiekcie naruto, w Collision Event with object shurik:

GML
hp -= 10;

with (other) instance_destroy();

 

if ( hp <= 0 )

{

// tutaj wstawiasz co ma sie stac jak naruto zgnie

}

 

a w sasuke z shurik2:

GML
hp2 -= 10;

with (other) instance_destroy();

 

if ( hp2 <= 0 )

{

// tutaj wstawiasz co ma sie stac jak sasuke zgnie

}

 

ale lepiej będzie jak sasuke też zrobisz wszędzie hp zamiast hp2

Opublikowano

dzięki przyda się tylko że problem jest w tym że kiedy gracz jest trafiony przez ten obiekt to wywala error. Coś jest nie tak z odejmowaniem życia, albo z nie wiem czym. Ja już nie mam pomysłu przez co ten error.

Opublikowano

Spróbuj tak :

 

GML
hp -= 10;

with (other) instance_destroy();

 

if ( hp < 0 )

{

// tutaj wstawiasz co ma sie stac jak naruto zgnie

}

 

GML
hp2 -= 10;

with (other) instance_destroy();

 

if ( hp2 < 0 )

{

// tutaj wstawiasz co ma sie stac jak sasuke zgnie

}

 

U mnie w GM jak zastosuje <= lub >= to wywala błędy !

EDIT : Ja też niewiem czemu !

Opublikowano

Też nic nie pomaga. Ciągle przy przy uderzeniu error. Stworzyłem na szybko nową grę i tam wszystko ładnie działa. Coś jest nie tak z moją grą.

Opublikowano

o matko

GML
//Obiekt sasuke2p, event Collision with shurik2

with (other)

{

hp2 -= 10;

if (hp<=0) instance_destroy();

}

zamien na

GML
hp2 -= 10;

if (hp2<=0) instance_destroy();

Tak samo w obiekcie naruto, tylko ze w evencie Collision with shurik, i zamien hp2 na hp

Opublikowano

nic to nie dało. Mam coś gdzieś zepsute, że odejmowanie życia nie działa i wyskakuje error. Zrobiłem drugą grę i tam wszystko działa. Chyba zaczne wszystko od nowa bo ta gra to mój pierwszy projekt i mam tam wszystko nawalone a teraz na spokojnie już bardziej ogarnięty będę i powinno być dobrze ^_^ . Dzięki wszystkim za pomoc.

 

Już wiem w czym był błąd. Miałem zrobiony wybór postaci na podstawie change instance i przez to ten error. Teraz dodałem te kody także do spawnu i wszystko działa.

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...