farflamex's Forum Posts

  • I'm implementing a load/save feature and the way I want to do it, is to restart the layout (which resets everything, destroys excess objects etc) and then reload the saved position over the top of the newly created objects. This will give me a nice clean reload.

    The problem is, to restart the layout cleanly, I also want to reset the global variables. Then when a new game is restarted, it will check a variable to see if the player is restarting from scratch, or restarting from a reload. If reload, it will then pop to the reload function.

    The problem is, where can I store the variable, because if I'm resetting all globals, that will also reset my 'Reload' variable which tells it to do the reload.

    The alternative of course is to just refresh the variables in code at start-up, but it's a bit long-winded if there's a simpler solution.

    So in short, is there somewhere else I can store a variable which will survive a 'Reset all globals' command?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, trying to remember what games usually use so I can use them, so it's a bit more intuitive. Unfortunately, I've just noticed that F5 and F6 seem to do something to Chrome anyway (F5 refreshes the page I think), so I can't use them. I'll just have to use my own keys and inform the player which keys they are.

  • Oh dear, that's a 3rd combination then :p

    Guess I could do something like F2/F3/F4 are save, F5 to F7 are load, something like that.

  • Is there a 'standard' key set-up for quick load and quick save? I seem to remember them being on F4 and F5 but I've seen them on F6 and F7 lately. Any opinions on which I should use?

  • Might not be the answer you're looking for, but I posted about this the other day and didn't get a response, so I'm not 100% sure why, but I also found that the viewport settings were off-centre by quite some way.

    It was really strange because my main arcade screen is centred perfectly and I just use WindowWidth and WindowHeight to find positions, but that doesn't work on a new screen. Then I found that I had a sprite that had the 'Scroll To' behaviour applied, so I added that to my new screen and suddenly it all seemed centred properly. Try adding an off-screen sprite with 'Scroll To' behaviour, then you'll find if you put an object at 0,0, it appears at the top left.

    I still don't understand what's going on here but it works. My screens are now perfectly centred, but as soon as I remove that sprite, I have the same problem.

    *I should point out that there's probably a 'proper' way to do this. If you do ViewPortLeft-ViewPortRight you do actually get the centre of the screen. I just found that very hard to work with as it means I need to do that math every time I wanted to place an object. But I'm sure there's a correct way of doing this.

  • Are you using the zip to Scirra Website option on the export menu? I know it sounds dumb, but when I first tried I didn't pay much attention and just zipped as HTML5 and got that error. You need to make sure you're using the Scirra option.

  • Very nice :)

  • It looks like an error with the variable 'forza', although maybe there's more code above this that we can't see. But as this code stands, it looks as though it will toggle the variable every frame. One frame does -forza, then the next frame it does -forza again so it'd keep toggling?

    The way I'd do it, I'd move the object towards/away from the magnet, just using the angle between the two, and just set up a seperate line of code for each situation. So....

    Animation Frame = 0

    Move Object at angle(x,y,x,y) + distance

    Animation Frame =1

    Move object at angle(x,y,x,y) - distance

    That might be a bit too simple for your needs though, it looks like you're trying to do it a bit more precisely.

  • It doesn't hurt to be efficient, but at the same time, your own time is probably more important than efficiency in some situations. C2 tests show that you can have 100,000 sprites whizzing around on your screen, so spending hours trying to shave off an object here and there probably isn't worth it.

    Although I think if you're targeting Android etc you do need to be more efficient, especially with memory. But if we're talking about 10 text objects or something, I wouldn't worry about it at all.

  • I'd like to see this changed, it's very fiddly to use and can really cause problems. But it was explained by Ashley in another post that this was a necessary change for stability reasons. Hopefully in the future a better solution will be found because it really is awkward and a major stumbling block the first time you come across it.

  • I'm not sure I like the idea of creating/destroying the object every time it's used, although I guess that's what happens with bullets anyway. Still, if it's something like a sword that the player is permanently carrying, I'd go with the fade effect. Start the fade, then when testing for collision, test the opacity of the sword. Don't destroy it if it'll be needed again constantly, you may as well just have it constantly animating whilst invisible.

  • One thing I'd say about title screens is that there's usually very little going on on a title screen anyway, so you don't need to worry about being incredibly efficient. As pointed out by Ashley and others, you shouldn't waste inordinate amounts of time optimising, unless it's really affecting your game. For a title screen, I'd just use loads of text objects and get the job done.

    Obviously if it's totally static you can just add text to your images in a paint package?

  • The wait command is one way, or you could add a timer to your player, which increases/decreases each tick/every x seconds or whatever, and then you can only shoot when the timer has reached a certain value. E.G

    Every tick : Player.ShootTimer - 1

    On key press :

    Player.ShootTimer <=0 : Shoot

                          : Set Player.ShootTimer to 30

    That's a coding approach, but the wait command should do the trick anyway.

  • Thanks. I was wondering if there was something wrong with the logic of checking if a variable is NOT a certain number during the picking process, but if your example works, then I can't fathom why mine doesn't. It's still picking the variable which is not selected, maybe I have to indent the 'pick' command or something.

    * Worked this one, it was an error in my code thankfully, the variables were being reset elsewhere. Doh.

  • I'm trying to pick a random object, from 50 objects, which has a certain variable set, but must NOT have another set.

    So I'm doing....

    Object Var1 = 1

    Object Var2 <> 2

    Pick a random Object.

    It's not working. It IS getting all the objects with var1 set to 1, but it's also occasionally grabbing objects where var2 = 2, which it shouldn't be doing?