farflamex's Forum Posts

  • I've just updated to the newest version and my game isn't scaling properly. I worked out that variables I was using 'WindowWidth' and 'WindowHeight' appear to be system variables now, so it's renamed them WWidth and WHeight. Problem is, they're all over my code as the original names. I can't work out if the editor has a search and replace thing which will work across all of my layouts. Is there a way I could change every 'WindowWidth' in my code to 'WWidth'?

  • I did get this working in the end, but don't think I have an example. I could probably delve into the old program and have a look, unless the other guy replies with his link.

    My finished game is here https://www.scirra.com/arcade/strategy-games/korelos-34

    Doesn't work for me, I still get a white screen, but apparently it works for others. Fly out a bit and get some enemies to fire at you and you should see that they're fairly accurate, although everything is moving so they pretty much do a 'rough guess' I think.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh I see. That's pretty good, I hadn't thought of that and yes, it would work for my game. I'm not sure which would be fastest / most efficient. Since my game is turn-based and the screens are mostly static, it might not matter too much but the tiled backgrounds do seem to be using a lot less objects at least. I'd be looking at 200 objects (9patches) v about 40 or so.

  • That's about 200 things on your horizontal axis which would seem to be tough to distinguish. If you want columns, the simplest way would be to create a single sprite and colour it using web effects, or to create one bar for each colour, and just scale it and clone it as you need.

    I didn't describe it properly. It would be 16 rows and 12 columns. Not 16 * 12 on each row.

    I would opt for the 9-patch object and reuse it as often as needed..

    or

    create the lines (and background) with the tiled background object (which would only take two sprites of 8x8px)..

    I was thinking about loads of 9-patches, basically one for each cell, which would solve it, including colouring each cell differently where necessary. But it's 192 cells which seems a bit many? Still, I do like this idea most so far. But what do you mean about the tiled background object using 2 sprites of 8x8? That sounds promising too, but I'm not sure how that'd work.

  • This isn't really C2's cup of tea, so I'm wondering, what's the best way?

    I need a league table (sports table), showing 16 teams and 12 columns for each team. This is always set, so that makes it a bit easier. I want to be able to resize the table depending on the size of my screen.

    My initial thought is to just draw the table in a paint package and then stretch it to the correct size. I could put image points in for the various boxes to allow me to place the text. Not sure if this is ideal, but I know how to do it. The only downside I can think of is that the initial graphic will be large and take up a lot of memory.

    Another thought is to draw a single row graphic in a paint package, and then just stack 16 of them ontop of each other, placing the text inside the graphic.

    Any of methods? Draw lines individually maybe?

  • It does actually work like this, I've just made a sample new project and it works fine, so there's something wrong with my program I guess. How do I delete / close the thread?

  • I might be missing something really basic because the obvious answer isn't working.

    Let's say I have 10 array objects and I set value.at(0) to a number, let's say 1 to 10 also (i.e the 1st contains 1, the 2nd contains 2 etc). To get the array that contains the number 5 at value.at(0), don't I just do..

    myarray.at(0) = 5... (so that's 'myarray -> Compare at X, X = 0, = to, Value = 5).

    Since I put the number 5 into the 5th array, shouldn't the above 'pick' that instance, so I now have 1 array picked?

    This seems like very basic stuff to me and it's how C2 works, but it's not working in my project and I'm running it through the debugger. My arrays definitely contain the values that I'm searching for, but it's just skipping past the event as though it's found nothing. Do arrays work differently?

  • That's a thought, doing it at the PHP end, instead of breaking it up at the C2 end. Mind you, I'm FAR more comfortable with BASIC in C2 than I am in PHP. I find myself spending 15 minutes on just about EVERY command in PHP because I'm so unfamiliar with the syntax.

  • Yes, I think you're right. I'll try the plugin or use my own methods for sending / splitting data. Thanks.

  • Thanks, that looks really useful in a lot of areas.

    I assume though that this means that you can't do what I'm asking, without a plugin? It can't be done directly from C2?

  • I have my string, json_encode'd from PHP. It looks like this.

    [{"Name":"Alford County","League":"Watnall Premier","ID":1},{"Name":"Highbridge County","League":"Watnall Premier","ID":3}]

    That's 2 rows, with 3 values each. I want to break it down into a usable form in C2. I was thinking that I could just plonk it into an array with Array -> Load From JSON string but I get nothing in my array when I do that.

    I thought there was something to do this automatically, but maybe I'm imagining it. Will I need to break the string down myself with 'tokenat' etc?

  • Yeah I couldn't find a way either. Since there were only 5, I had to ensure that they were created in the order that I wanted to tab-order them. It's a bit fiddly, a case of create 1 login box, create 2 password boxes, create 1 login box, create 1 password box. But it does work that way at least. Would be interested to know if there's another way, but this works for now. Thanks.

  • Am I missing something obvious in the editor? I have 5 controls and if I hit the tab key, I want to tab through them in a different order to the order that C2 is using. For example, I have a login page which has a login textbox, then 2 password textboxes (for registration). It then has a login textbox and another password textbox on the other side of the screen, for logging in. If you're in the first login box and hit tab, it goes over to the other login box (presumably because they're the same type of control and were created together?), but I want it instead to go down to the first password box.

    Is there a simple way of doing this, other than creating completely separate boxes or redesigning my screen?

  • Thanks, lots of really useful advice there

    I've got it working now, I was making some minor errors. I'm using PDO on the server side, so the solution to protecting against injects appears to be the bindparam instruction. I was confused about the very basics of how to send my username as part of the post in C2, but I think it's simply...

    UserName=&Textbox.Text (build as a string then send in the 'data' part of the AJAX Post to URl).

    Then at my server side, I now have....

    // Already connected to database....

    $UserName = trim($_POST['UserName']);

    echo $UserName; // Obviously this is just for testing, it's picked up by C2 as the AJAX.Lastdata

    $db->beginTransaction();

    try {

    $query = $db->prepare("INSERT INTO Users

    (Name)

    VALUES (:Name)");

    $Name = $UserName;

    $query->bindParam(':Name', $Name, PDO::PARAM_STR);

    $query->execute();

    $db->commit();

    Not sure if this is all a bit over-cautious, but it does work. From what I've read, the whole 'bindparam' procedure does protect from injects etc anyway.

    One thing that was causing me problems was the strict capitalization rules. For example, 'Username' and 'UserName' are not the same, so that sent me wrong a few times

    Thanks again for your input, that really helped

  • I'm just returning to this after a break. I understand the basics of C2 and PHP etc, but I'm having a bit of trouble getting my head around a few things, because when I check PHP tutorials / articles online, they usually assume the request has come from a form or an url. So in short, let's say I'm sending a login request to my server from C2, what do I send and how do I retrieve it in PHP?

    E.G C2 would be something like AJAX - Post to Url, I use a tag, the url for the php script, 'POST' and the data. How do I post the data? Do I just send a string, e.g the user name that he typed?

    I've managed to produce a script which collects the data and echo's it back out and I also know how to add it to my database, but I want to sanitize it first. Most PHP articles suggest something like ..

    $myusername=mysqli_real_escape_string($db,$_POST['username']);

    How does the POST find 'username' from my C2 string? Do I need to add something like 'username=name' as part of the string I'm sending from C2?