Page 1 of 1

GMK Help?

Posted: Mon May 16, 2011 7:59 am
by md
I'm making a game, and for some reason, the boss is invisible? :?

I've done all it's events and it still shoots out it's bullets and moves how it's supposed to, but it's invisible.
  • -Visible is ticked.
    -When I put it in a different room (even the main menu), it's invisible.
    -All it's "Step" event has is a code saying if it looses all it's health, it gets destroyed. Here's my code:

    Code: Select all

    {
     if &#40;obj_boss1.HP<1&#41;
     &#123;
      instance_destroy&#40;&#41;
     &#125;;
    &#125;
Does anyone know why? :D
Thanks!!! :D :)

Posted: Mon May 16, 2011 10:45 am
by MyNameIsKooky
Do you have a draw event? Draw events always elimate the default sprite for the object and replace it with whatever is drawn.

Aside from that, I can't really see the source of your problem unless you give all of the object properties for the boss.

Posted: Mon May 16, 2011 8:55 pm
by boywhoflies
If it's not the draw like Kooky said, Game Maker is a noob again. Cut all your code and paste it in the same place, I guess. That somethimes works for me.

Or you put in a diffrent object with the same sprite by mistake?

Posted: Tue May 17, 2011 5:53 am
by md
MyNameIsKooky wrote:Do you have a draw event? Draw events always elimate the default sprite for the object and replace it with whatever is drawn.

Aside from that, I can't really see the source of your problem unless you give all of the object properties for the boss.
I do have a draw event, all it has is a code that draws the enemies health bar.

Code: Select all

//Draw the enemy's health bar.
&#123;
 draw_healthbar
 &#40;
  220,
  view_yview+35,
  420,
  view_yview+55,
  HP,
  noone,
  c_fuchsia,
  c_fuchsia,
  0,
  0,
  1
 &#41;;
&#125;
Do you see any errors. Thanks! :D

Posted: Tue May 17, 2011 5:58 am
by md
md wrote:
MyNameIsKooky wrote:Do you have a draw event? Draw events always elimate the default sprite for the object and replace it with whatever is drawn.

Aside from that, I can't really see the source of your problem unless you give all of the object properties for the boss.
I do have a draw event, all it has is a code that draws the enemies health bar.

Code: Select all

//Draw the enemy's health bar.
&#123;
 draw_healthbar
 &#40;
  220,
  view_yview+35,
  420,
  view_yview+55,
  HP,
  noone,
  c_fuchsia,
  c_fuchsia,
  0,
  0,
  1
 &#41;;
&#125;
Do you see any errors. Thanks! :D
Oops, there's a little more in my "Draw" event. These are my actions:
  • "Set the Colour"
    "Set the Font"
    "Draw a Rectangle"
    "Draw a Text"
That's all I have in my draw event.

Posted: Tue May 17, 2011 10:11 am
by md
MyNameIsKooky wrote:Do you have a draw event? Draw events always elimate the default sprite for the object and replace it with whatever is drawn.

Aside from that, I can't really see the source of your problem unless you give all of the object properties for the boss.
You were right. It was the draw event. I tried putting it with a different object and it works!

Thanks!!! :D :D :)

Posted: Tue May 17, 2011 8:34 pm
by boywhoflies
I see what happened.
You drew the healthbar, which disabled the sprite. In those cases, I use this code:

Code: Select all

draw_sprite&#40;sprite_index,image_index,x,y&#41;
. That draws the sprite normaly(same possion and all that. Don't change any of it...). The only problem is that image_angle dosen't work with it.

I'm just putting this down for other times, I know you solved it. :P

Posted: Wed May 18, 2011 12:36 pm
by Blast!10
boywhoflies wrote:The only problem is that image_angle dosen't work with it
Easy to solve if you have the Standard/Pro edition:

Code: Select all

draw_sprite_ext&#40;sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,image_blend,image_alpha&#41;;

Posted: Wed May 18, 2011 10:43 pm
by boywhoflies
I have pro. That works out well.
Thanks! :D

Posted: Tue Jul 05, 2011 3:12 am
by md
Ok, I've got another question.

For some reason, when I put a "+" sign between a text to separate it, it comes up with this error:

Code: Select all

___________________________________________
ERROR in
action number 23
of Draw Event
for object obj_controller&#58;

Error in code at line 7&#58;
     "BONUS&#58; " + global.bonus
                        ^
at position 23&#58; Wrong type of arguments to +.
But it doesn't do this to my other game when I use usernames!

Can someone please help me?

Thanks! :D

Code:

Code: Select all

&#123;
 draw_set_halign &#40;fa_middle&#41;
 draw_text
 &#40;
  view_xview+432,
  view_yview+180,
  "BONUS&#58; " + global.bonus
 &#41;;
&#125;
I thought it might be because I was using a variable in my other game that was a word, so I might have something to do with numbers and word errors. :?

But still, it's confusing.

Posted: Tue Jul 05, 2011 5:46 am
by Blast!10
"BONUS: " is a string. global.bonus is a real value. It's called a type mismatch - you have to concatenate both values as strings, in this manner:

Code: Select all

"BONUS&#58; " + string&#40;global.bonus&#41;

Posted: Tue Jul 05, 2011 6:29 am
by md
Blast!10 wrote:"BONUS: " is a string. global.bonus is a real value. It's called a type mismatch - you have to concatenate both values as strings, in this manner:

Code: Select all

"BONUS&#58; " + string&#40;global.bonus&#41;
Thanks, I'll test it now!

Posted: Tue Jul 05, 2011 6:40 am
by md
It worked!

Thanks Blast!10! :D