Lag Spikes When Creating Objects

0 favourites
  • 8 posts
From the Asset Store
Fully animated spike ball characters game sprite.
  • Hi

    I'm creating a survival game (mobile)

    so the player must kill a lot of enemies to get the highest score

    The problem is, when i tried to create the enemies, maybe (~10-20 per wave). There's a lag spikes (dropped the fps from 50-60 to 30 - 40).

    I put all of my enemies sprite into a different layout named "bank"

    I read on the forum that i must put the sprites that i want to create outside of "THAT" Layout.

    I cannot put it on different layout (in my case "bank" layout).

    When i tried to put the enemies sprite outside of the game layout and destroy it at start of the layout,

    the player_kill_counter variable is counting the enemies that destroy outside of the object

    because, my event sheet for killing is

    Enemies on destroy -> add +1 to player_kill_counter variable.

    So how do i do this?

    Thanks in advanced

    http://imgur.com/a/pkyLg

  • How are you creating your enemies? In a loop? One at a time over X seconds?

    How complex are the enemies? Are they made of several parts, or just a single sprite? Are they effect heavy?

    How many other objects are in your layout? Are those effect heavy or doing complicated movements/animations? What is the total object/sprite count?

    To give more accurate information we need to know more specifically about the problem. There is likely a bunch of ways to optimise the events to make it run smoother - but without knowing more, or having a capx or even an event sheet screenshot to look at, it's difficult to really say for sure.

    ~Sol

  • How are you creating your enemies? In a loop? One at a time over X seconds?

    How complex are the enemies? Are they made of several parts, or just a single sprite? Are they effect heavy?

    How many other objects are in your layout? Are those effect heavy or doing complicated movements/animations? What is the total object/sprite count?

    To give more accurate information we need to know more specifically about the problem. There is likely a bunch of ways to optimise the events to make it run smoother - but without knowing more, or having a capx or even an event sheet screenshot to look at, it's difficult to really say for sure.

    ~Sol

    Hi, sorry for not posting a screenshot

    Just updated the post with the screenshot of the code

    -The enemies are checking the distance of itself and the player, if the enemy is in distance, the enemy attacks the player

    -For right now, the object count is 230 (without the enemy & tilemap for my background)

    -The animation for each enemy is only 3-4 animations with 1-8 frames.

    -Using the brightness effect (so when the enemy got hit, they blink to white for a second)

  • What device are you testing this on? It doesn't look like it should be causing ANY problem for fps, at least as far as I can tell from the events you've shown.

    What size are the sprites you're using? Is this all lo-fi graphics or more HD style?

    ~Sol

  • What device are you testing this on? It doesn't look like it should be causing ANY problem for fps, at least as far as I can tell from the events you've shown.

    What size are the sprites you're using? Is this all lo-fi graphics or more HD style?

    ~Sol

    (Without the Enemy Spawning Yet)

    Ipad 2 = 30-50 fps

    Nexus 5 = 50-60 fps

    Iphone 4 = 5 fps

    Iphone 5 = 50-60 fps

    Iphone 5s = 60 fps

    Iphone 6s = 60 fps

    Samsung Galaxy Note 3 = 50-60 fps

    (When the enemy spawn)

    Ipad 2 = 20-40 (~20 when the enemy being spawn, after all of the spawning is done, the fps become 30-40)

    Nexus 5 = 50-60 fps (~30 when the enemy being spawn, after all of the spawning is done, the fps become 40-50)

    Iphone 4 = 5 fps (Cannot even move)

    Iphone 5 = 40-60 fps (~40 ish when enemy are spawning, and 50-60 after spawning is done)

    Iphone 5s = 60 fps (~45-50 ish when spawning)

    Iphone 6s = 60 fps (~45-50 ish when spawning)

    Samsung Galaxy Note 3 = 50-60 fps (~30-45 when spawning)

    The problem is the lag when spawning for a few seconds

    Not placing all used objects in the layout

    If objects are not placed in a layout but are created by events, Construct 2 will load the textures for those objects the moment you create them. This can cause a momentary pause or "jank" and make the game feel less responsive. This can be avoided by placing any used objects in the layout. They can be placed off-screen and destroyed on startup to avoid interfering with the gameplay. Then Construct 2 will preload all their textures when the layout starts, avoiding any "jank" as they are created and destroyed at runtime.

  • The fps looks respectable on devices less than 3-4 years old... that's not bad really.

    Still you don't mention about the resolution you are using for sprites and things like that. A handful HD graphics will perform a lot worse than thousnads of lo-fi "simple" graphics.

    ~Sol

  • The fps looks respectable on devices less than 3-4 years old... that's not bad really.

    Still you don't mention about the resolution you are using for sprites and things like that. A handful HD graphics will perform a lot worse than thousnads of lo-fi "simple" graphics.

    ~Sol

    It's a small project

    The Game Layout is 320x180

    The Enemies sprite is vary from 16x16 to 48x48 only

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah you shouldn't be getting lag like that... something else isn't right.

    Do you have some open ended loops running, or maybe some conditions that are being checked too often that perform complicated actions?

    Without seeing your capx file it's going to be practically impossible to say for sure.

    ~Sol

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)