OlivierC's Recent Forum Activity

  • So on the game I'm working on, pressing the Esc key pauses the game and brings the menu (resume, options, quit...), just like in many games on PC.

    I wanted to mess with the Browser plugin fullscreen feature. When the player click the Start button in the main menu, I request fullscreen. Works fine and all, except when I press the Esc key to pause my game, the browser exists fullscreen. Weird, I thought the fullscreen toggle key was F11. Plus I remember reading in the manual that Construct prevented the default browser behavior when you assigned an action to a shortcut key.

    But then I realized, the default fullscreen key is indeed F11, at least in chrome and firefox. If you press F11 or go to fullscreen using the browser's menu, it does say "press F11 to exit fullscreen" and pressing Esc does not cancel fullscreen. It's only when you request fullscreen through Construct (or more generally javascript I imagine) that Esc becomes the key to exit fullscreen. And since it's not the original default key for fullscreen, having an event assigned to that key in construct does not prevent from leaving fullscreen.

    So, is it that a bug or is it like this by design?

  • Well from what I understood, Cocoon does not support layout-by-layout loading. This means when your game starts, Cocoon will load all the sprites in memory, project-wide, regardless of which layout is being displayed. If you have a small game with two or three layouts, this should not be a big deal. If your game contains many layouts with many different assets, this is more of problem as it will load everything in the RAM, quickly reaching the phone's memory limit if you happen to use big images. Iphone "only" has 512mb of RAM, lots of which is already used by the OS and other process running in background. So if you happen to have over 200mb of images in your game loading at the same time, you're in trouble. Some people said their game won't load at all for that reason.

    I have read there are problems with some sounds not playing too.

    The big issue is that people of Cocoon don't seem to be in a hurry to fix those problems. Instead they prefer to add new features. Again, this is based on what I could read on this forum.

  • I also use many event sheets and groups, but I do agree the search tool could use some improvement. A "find next/previous" design like you find in any kind of editor or browser would be much nicer. If I decide to modify a function name, I need to find and update the events where I call this function. with the current search system, it's a pain in the ass

  • Thank you for your reply, you seem to confirm what I was afraid of, that loading animation dynamically is almost impossible, too much of a hassle compared to the actual benefits.

    Anyway, here is a link to my capx for people interested. I updated it, since I typed the message above, added a temporary start menu, just to check that I can actually load the dynamic layout from a different layout. Also added a loading layer that is displayed while images load.

  • Short version: I'm creating my layout completely dynamically, including loading sprite images, using XML. But is it worth the trouble? does it actually save initial download time and memory? How about animations? If you can't create them dynamically, why bother?

    Hello everyone,

    First of, let me say that I posted this here because I don't think it's a "how do I", I'm asking for advises and opinions, but if any admin think it should be moved, feel free to do so.

    So I started working in Construct about a month ago, I really like it. My project is to make an old school point and click game. The thing is, I want to make a long game, not something you complete in 10 minutes. That means many areas to visit, meaning many layout with many images.

    I already made some research about having many images and I know it can be problematic, because the game has to download everything first, and on iOS/android, Cocoon also loads all the images in memory, regardless of which layout is active, quickly reaching the phone's memory limits.

    Plus, having dozen of layouts can be difficult to manage, especially if they must all match the same template. If you decide to update it later because you forgot something, like adding an extra UI layer, that means updating all the existing layouts for compatibility

    So I decided to create one single layout for all the scenes, which already contains all the required layers and the pause screen, the player's sprite and then have everything else loaded dynamically with XML files. It creates empty "background" sprites on specific layers, set their size and position and load the images dynamically. Sounds overkill but I made a small proof of concept and it works!

    When you move from one area to another, you just set a global variable with the name of the XML file for the new area, and restart the layout.

    So far, it loads the background images, the player's initial position, the walk areas, invisible wall for collisions and layers parallax. It does not handle interactions with clickable objects yet, but that's the next step. Unique events that are proper to each layout will be loaded for a separate event sheets. I also need to add an opaque layer on top of everything, saying "loading..." that I show at the start of layout and hide once all the images are loaded, so you don't get to see a partially loaded scene.

    I'm not at home right now so I can't post the capx, but if you are interested to see it, I can post it later.

    To generate the XML file, I'd have a separate project with the same template (size, layers...), I'd just build the new scenes, and at runtime I'd call a function that loops through the scene elements to build the matching XML string and output it in textbox, that I can copy/paste into a file. That still needs to be done, but its' definitely not the hardest part.

    So that sounds cool an all but I still have some issues:

    I store the images to load in the project Files directory, so I don't have to worry about hosting them somewhere else and dealing with absolute URL in events.

    But the manual says: "When published, the file is also cached for offline use alongside the rest of the project".

    Does that mean that all the files in the Files folder are downloaded with the other assets when the game starts, or only the first time they are requested?

    The first case sounds a lot more probable and makes more sense. That means loading images on demands becomes almost useless if said images have to download first for caching, you still end up with the same initial download time as if the images where already inserted in the sprites. But it would still help with memory problem on cellphones though, because they would not be loaded in RAM until needed.

    The other problem is when it comes to animations: The dynamic image loading can only handle static images, which will do in most cases... But what if want to have animated sprites with several frames? Let's say I want to have a windmill in the background, with a looping animation. I know this could be done by rotating a sprite, but whatever, let's say I want it to be one animated sprite. As far as know, sprite animations can only be built in the animation editor. You can eventually replace an animation frame with the load URL action, but the frames themselves, even if they are blank, must be created manually first. Same for the looping option, it must be set in the animation properties.

    One workaround would be to have have several blank animated sprites, with various animation length (let's say 2,4,8 frames). Then you'd design your animations accordingly. Then on load, depending on the number of frames, you'd pick the appropriate sprite and load each frame dynamically. In theory that should work, but that's really overkill and less efficient than having one sprite sheet per animation, because it means one request for frame.

    The other solution is to simply create individual sprites for animated ojects, with the animations and images already set up in the project and to just not worry about download/memory, like you'd do on any small game, but still create them dynamically at runtime. But then I'm not sure, would I still have the memory issue on cellphones? I read that Cocoon does not load images layout by layout but all at the same time. Does that mean Cocoon loads all images in the project, regardless if the sprites are on any layout or not, or that it loads all the sprite that are initially on layouts but not the one that have not been created yet?

    Because if it's that last case, that might be the solution: prepare all the sprites in the project (regardless if they are stills or animations), without putting them on the layout and then create them dynamically at runtime. Sure you'd have to download everything ahead, but at least the memory problem would be avoided.

    The new problem here is that, unlike when loading images from URL, you can't have one function to create any sprite you want using a variable, since you must manually pick the specific sprite when you create the action.

    So if you want to go that way, you're just better off forgetting the generic loading through XML and just have a specific event sheet for each area that build the scenes (just what I wanted to avoid)

    So let me know what you think. What do you think is the better option? I'm missing something? Is it overkill? Am I wasting my time for nothing? am I over my head?

  • I think what he meant is he is more worried about people just copy/pasting his whole game and host it as is on their own server, making ad revenues with his game, without his consent, not actually stealing parts of the assets/code. Just like some sites do with images (9gags and such).

  • One way that could work (I have not tried, just came up with it, so I'm not sure) is to use the Browser plugin to check the domain name on which the game runs. Supposing you know where you're going to host it, you can have an array which contains a list of allowed domains. On layout start, check if the current domain belongs to that list. If it does not, that means the game is stolen, you can do what you feel like: prevent the game from continuing, display a warning message, redirect to your original host, force the browser to close the tab...

    The downside is that you have to plan ahead where it will be hosted. If you want to host it on a new site, you'd have to update the list of domain and recompile.

    Edit: You could have the list of domains in a separate xml file that you'd import with an ajax request, that would be easier to update, but it would defy the purpose, since you would have to host it with your game (no cross domain ajax!), so anyone who grabs your game, will grab this list too and can edit it.

  • Yes you can do it: Z order (at the bottom of the page)

    When you create an action, select the object you want to change the Z-Index, then in the available actions, scroll to the bottom, it should be there

  • Have you tried the Pin behavior? when it comes to positioning, it's very handy (pretty much removing the need to worry about any positioning at all). You just position your sprite in the layout view, pin them, and there you go.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you need to do it at every tick? Since you set it at a constant 0.2, why don't you just do it once when the layout start? If the scale never change, there is no reason to to repeat it on every tick (unless I'm missing some information). I know it's a simple operation and that it's not significant enough to slow things down, but it's good practice to try to keep things optimize, even for the small things

  • Yeah, there is no expression to get a sprite scale, while you can set it (as far as I know, I might be wrong, but I think it's because you can modify height and width separately, so there is not one unique scale). So one way to do it is to store the original width or height of the first sprite in an instance variable when its scale is still 1:1 (like on layout start). Then you can calculate the sprite scale at any time by dividing the current width by the original width.

    It would be something like this:

    Every Tick -> Sprite2 scale = Sprite1.Width/Sprite1.originalWidth

    Not sure if it's the most efficient way, but that should work. There might be a workaround that does not require using variables.

  • I would look into effects to create different mood without having to create different versions of your assets. You can use effects to darken or change the color of the whole layout

OlivierC's avatar

OlivierC

Member since 7 Sep, 2013

None one is following OlivierC yet!

Trophy Case

  • 11-Year Club
  • Coach One of your tutorials has over 1,000 readers

Progress

12/44
How to earn trophies