Game is still lagging!

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • I made a fairly straightforward game and compiled it through cocoonjs. The Game Worked fine but had problem putting ads on using admob so decided to compile through Intel xdk. After downloading it through the Google play store I noticed that it lags a lot.

    I made the following changes to try and solve the problem:

    -changed all text to sprite font

    -reduced collision points on the sprites to just 3

    -changed webstorage to local storage for the highscore so that on start of layout it runs better.

    -destroy sprites outside of layout

    -changed properties to rounded pixels

    Just to quickly explain the game. It consists of a player on the left side of the screen. 4 types of enemies are spawned every random 1.3,1.8 seconds. The enemies are in a family and randomly chosen when spawned. If the player destroys the enemy a point is gain if not then It's game over. Simple!

    I would appreciate it massively if someone could help me out with what the issue may be.

    Thank you

  • I'm not sure about admob, but you can go through this list and see if any of it helps. It's something I borrowed from a thread to help me with my projects. It's pretty much a check list to help with efficiency. Just salvage what you can from it. I know the post was to someone else, but there might be something useful. Also someone else might be able to help better with your specific questions.

    1.- for the red character: Use a container for the eyes

    2.- for the red character: For the jump use image points or use EaseTween.

    3.- For the whole project: use Powers of two in the sprites.

    4.- Use PNG8 for the background

    6. - Keep pixel rounding on.

    7.- Don't play animations too often.

    8. - Remove collision from backgroun images, and uncollidable objects.

    9. - Pre-plan as much code as possible and use function object to cut back on events.

    On code:

    6.- Use delta time, you have lots of actions using time. That will help on frameratesss.

    7.- Also, use Groups, your code needs it, a lot.

    8.- And Functions, they can pass variables and data.

    9.- And Families, you are using lots of single events for destroying any block. Example on how to fix this: Assign instance variable ID "destroyOnClick" to anything that you want to be destroyed on click, and create a Group for that.

    10.- Why use WebGL if iOS doesn't support it?

    11.- The code is ALL the time checking and updating the End Screen (just remove the forest background to see what I mean).

    12.- Hide the End Screen btw., and only show it or create it when the red thing is over the Goal block.

  • can you send me the link to the forum page this is from. Only because I cant understand some of it since it is out of context.

    3: For the whole project: use Powers of two in the sprites?........what does it mean by that? 2,4,8,16? I'm confused

    7: Don't play animations too often......all my enemies are an animation that are spawned every 1.3-1.8 seconds. could this be the issue?

    On code:

    6.- Use delta time, you have lots of actions using time. That will help on frameratesss.....when would i be using this?

    7.- Also, use Groups, your code needs it, a lot.......what does this mean?

  • "can you send me the link to the forum page this is from. Only because I cant understand some of it since it is out of context."

    Just to warn you it's an old post about an unhappy customer with the same kind of problem. Lag... BUT the users swear it's because of the persons own doing, and great things are made in construct... so likely he could have improved his code/image performance by following proper procedures.

    good-scam_t82598?start=20

    "3: For the whole project: use Powers of two in the sprites?........what does it mean by that? 2,4,8,16? I'm confused:

    • Yes. Check out this article for more information. Sprites should be in boxes that are to the power of 2,

    http://www.katsbits.com/tutorials/textu ... of-two.php

    same with tiles and backgrounds. This article should help a lot with that.

    https://www.scirra.com/blog/112/remembe ... our-memory

    "7: Don't play animations too often......all my enemies are an animation that are spawned every 1.3-1.8 seconds. could this be the issue?"

    I'm not sure about the depth of Construct and its capabilities. This would be a question best suited for another member. I would say to watch where you're spawning enemies though. If they don't need to be on the screen, maybe they shouldn't exist (that is if you spawn them off screen). Like spawn enemies a few px off screen before the player gets to them (to make sure your not spawning baddies the player can't see), destroy anything that falls through the floor or off screen... if you're using gravity only use it on objects that need it and are in player view. (except in important cases)

    On code:

    "6.- Use delta time, you have lots of actions using time. That will help on frameratesss.....when would i be using this?"

    • Use delta time any time that you lerp, or move something.

    Say you have an even press right key. and that event does player.X + 12 every tick. What you really want is player.X + 12 * dt. This will make your game framework independent. Without delta time your movements are set to frame, thus effected by processor speed. dt

    Here's some knowledge for you on DT

    https://www.scirra.com/tutorials/67/del ... dependence

    7.- Also, use Groups, your code needs it, a lot.......what does this mean?

    • I can't really help with families and groups, I'm still learning this. One thing I can warn you is that if you don't know how families work you'll get some bad behavior, so don't implement these unless you need them, and you know what they do. Backup your project and have a good copy before you make any major edits...

    Sorry, I couldn't give more information, but if you read those articles it'll make your game better <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Some really nice info on improving memory when exporting, I will be reading this through step by step shortly! Thanks!

  • thanks JeremyBenson11 i'll have a go.

    for when i spawn the enemy should i change the every 1.2,1.8 seconds create enemy to dt time?

    and also where i have every 5 seconds add 1 to global variable. should i also change that to dt?

  • JeremyBenson11 I read up on the DT it says that for things such as every x seconds you don't use dt. so I dont think dt is the issue.

    I made the mistake of not testing my app as I went along. I'm really unsure what the problem is and have been suffering with the problem for several months now. I can always PM you capx if you're good with understanding C2?

    I don't think it is due to the webstorage or local storage that I am using since everyone else uses it in their apps. Could it be the images I made for the sprites? they're only around 100x100px and i made them in adobe illustrator and just exported as a standard PNG and the image size isn't very large, much less than 1mb so i don't think that is the issue.

    To be honest i'm honestly stuck with what it could be. I have no idea at all.

  • Hm, I don't think I'd be able to help. I'm not a guru by far, and have my own questions really. What did you use for you images? For things like backgrounds and stuff you're not supposed to use sprites. There's tiled background and tiled map. Using too many objects can slow your game down.

    The reason being is sprites have member data and functions attached to them. If you use these for something that's not going to use the functionality it's a waste of memory.

    Have you heard of classes in programming languages?

    well a sprite might store: image, position, angle, rotation, yad yad yad yad.. Then functions to rotate it, and everything else..

    Where as an image object might just store a rectangle, texture, and vector for location.

  • Check this out for your image compression: https://www.scirra.com/tutorials/1154/d ... h-pngquant

    Just wondering. You have a player that moves right? By keys, or buttons? That's where you want to use dt. If you don't your game will run different on different speed computers. That's what dt is for to set things to a second timer, rather than frame rate alone, which is run by cpu power.

  • As a side note your first comment said that you had the issue only when you added admob? If this is truly the case, and you have made sure everything is optimized properly: use tile image for images that aren't sprites, use right compression for images, use the right sizes for the right case, use animations only where necessary.. Then I would say your issue is just with admob..

    This is a related post with the same issue.

    If I were you I would contact Ashley (Support here), and possibly whoever made the plugin, the thread above says Google.

    If you can't fix the bug you may have to settle on a game without adbomb.

    Not sure why someone would put ads in a game though. Imagine playing Zelda link to the past on snes, and having a banner ad ..

    There are other monetization options for a site too: Adsense... Also, you can always sell your own adspace online. If you had 100,000 players on your site sell you adspace for $500-1000, or whatever the going rate is. You'll make 10X more money, and your game wont have an ad on it... players will thank you for it too

  • Post a capx.

  • ahhhh right I understand. The player is stationary but rotates on touch.

    I will have a look at the image compression link, thank you

  • Tekniko can I PM it you?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • JeremyBenson11 sorry If my post was unclear. It wasn't caused from admob. I previously wrapped the game using cocoonJS which i found was more efficient for my game in terms of loading speed etc, i just found it ran quite smoothly. But i wasnt able to integrate admob with it very easily so decided to swap over to intel XDK instead so that i could incorporate the admob into my game which worked fine.

    However the game didn't run as smooth and seemed to lag more. I was suggested yesterday to look into the resolution of my images. I sent one of the C2 members the capx and they said that their phone was showing 10% of its real resolution?

    I made the sprites in adobe illustrator. Maybe I made the images with too higher resolution when exporting or something? If it makes any difference the colour of the images is a lot more vibrant on my android than on my PC. Not sure if that is relevant at all. Going to try and look into the resolution of the images

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