Game Lagging

Oringles

  • Posts: 20
Hey guys, Oringles here.

For some reason, my game laggs after a couple of seconds. I've attached the .swf standalone version of the game to this post, so see for yourself. I was just improving the graphics for the gem and the text, and when I tested it, it started lagging. I don't know how to fix this. Please help.

Thanks,
Oringles

[P.S.] Tell me if it works fine for you, it may just be my flash player.
[P.P.S.] It's after you click play, wait a couple of seconds.

Sunflower

  • Posts: 591
Blind guess: did you use "do every [ x ] seconds" block? Did you put it in "when updating/always"? If so, the task to do every [ x ] seconds will be spawned every frame! If you want something to be performed every certain number of seconds, you should put it in "when created" instead!

---EDIT---
Alright, apparently not this time. It seems that there's something which causes "ERROR: null object" print. I'd need to know the exact logic to see what can be possible cause, but yes, this null object thing might cause your game to lag on slower computers.

And in case you didn't know, you can check print console by pressing tilde (~).

Apart from the prints, I don't see what can cause the lags. And the error needs to be dealt with anyway. O.o'

« Last Edit: May 13, 2012, 12:49:59 am by Sunflower »

Oringles

  • Posts: 20
Ah, thank you for the feedback. I don't think I do the check [ x ] thing, and I don't know what you're talking about tilde.

In the update to my game (when it started lagging) I had made a behavior that lowers your score upon a certain actors death. I guess it checks every second, which causes the lagg. To prove, I disabled the behavior on the scene and it stopped lagging.

The only problem now is that I need a behavior that lowers score on actor's death that doesn't make my game lagg! I would appreciate any help I could get with this, as I am still a newbie. :3

Thanks,
Oringles

Edit:
I fixed it so that it doesn't cause lagg, but it still won't subtract points.

« Last Edit: May 13, 2012, 07:51:05 am by Oringles »

Sunflower

  • Posts: 591
When playing the game, press the "~" button and the console will appear: a semi-transparent dark window with some white text. I attached the screen with the console from the old version of your game. As you can see, it's filled with "ERROR: null object". I don't really know what can be "null object" there, but since lag disappears when you disable the score-lowering behavior, I take that it's somewhere there. Perhaps you could post screen of this behavior or something? O.o'

Oringles

  • Posts: 20
I think I found what caused the lagg. I'll attach a split picture to compare when it lagged and when it didn't. Thank you for your help so far.

Sunflower

  • Posts: 591
Is it a Scene behavior or an Actor behavior? Also, what are you trying to achieve with "if <[Actor] is alive>" thing? What Actor you want to check if it's alive?

I think that this "Actor" may be this null object thing which causes all these prints and such.

Oh, and never put "do after" or "do every" blocks inside "always" block, unless you REALLY know what you're doing.

Oringles

  • Posts: 20
Is it a Scene behavior or an Actor behavior? Also, what are you trying to achieve with "if <[Actor] is alive>" thing? What Actor you want to check if it's alive?

I think that this "Actor" may be this null object thing which causes all these prints and such.

Scene behavior.

The actor is the bomb that, when clicked, will make you lose the game. Since there's nothing (or at least I can't find it) that checks if it's dead instead of alive, I use that.

I think it'll work now, because I'm creating another (hopefully working) behavior that will make you press [ENTER] to go back to the title scene, or restart the game (hopefully the latter) because the score keeps throughout scenes. Or, I could just go back to the title while setting 'score' to 0 after submitting it to the Kongregate high scores.

Sunflower

  • Posts: 591
Actually, you don't need to know whether the bomb is alive. All you need is to react properly when the bomb is killed.

So in a behavior where you kill the bomb by clicking on it, not only kill it. Do something like that instead:

Code: [Select]
when [Self] is pressed (however you check that)
  set Score to [[Score] - 500]
  kill [Self]
I assumed that the bomb is killed in a behavior attached to a bomb, so I used "Self" thing. Also, note that there should be "set Score to []" block instead of "set game attribute [Score] to []"! The latter doesn't work that way!

Oringles

  • Posts: 20
Thanks, you're amazing.

Would attached work, considering the behavior "Die on Click or Touch" is attached to bomb?

Thanks!

Sunflower

  • Posts: 591
I think it would, except the "set Score to" block should be purple, no blue.

You can find "set Score to" block in Attributes palette, specifically:
Attributes >> Game Attributes >> Number Setters

Oringles

  • Posts: 20
Thanks! Also, this is kind of off topic but do you know how to update your game on www.kongregate.com? I totally forgot how and now I can't apply the new update ._.

Thank you for all your help,
Oringles

[P.S.] I uploaded the newest version for your enjoyment. Thank you for all your help, couldn't have done it without you!

[P.P.S.] Nevermind the strikethrough above. I figured it out :3.

« Last Edit: May 13, 2012, 09:36:08 am by Oringles »

fitz

  • Posts: 1
I am experiencing the same problem. I created a new Actor from scratch in GIMP and after a few test runs it started lagging the entire game. I even deleted the character but the game still lags.. I restarted computer and still can't seem to figure out whats causing it. Any suggestions would be greatly appreciated, thanks.


« Last Edit: June 04, 2013, 10:29:33 pm by fitz »
T-rev.or?