StanBond's Forum Posts

  • More or less I've managed to do this, for testing I've manually inserted the saved data into variable.

    The issue I can't overcome is that in order to maintain whole numbers I had to use round, the problem now that values of less than 0 now are being rounded to 1 and as you can see it will add 1 to stamina, so in other words if user will keep on refreshing the page stamina will grow by 1 each time.

  • Use more sprites. The more detailed motion it is the more realistic it will be

  • Thanks for the suggestions however I've faced some awkward issue.

    I've prepared an illustration for the better understanding of the problem.

    When ever I press the attack button on the bottom left, it deducts from stamina 2 points, then there should be a timer that starts counting 2 minutes after which there will be refilled one point and make it 99/100.

    This is where the issue occurs, whenever I try to take the current time using the Browser, I take the time when this action was made, add to it the 2 minutes in milliseconds, and perform another event check if this value is < than the current time, then there should be an increase of stamina by 1.

    Following this method, if i'll have for example 67/100 points, i won't be able to see 68/100, 69/100, ..., n/100 it will simply jump to 100/100 once the total time has passed. Moreover, considering this in cases when the user logs out, and returns, some time has passed so he must have the corresponding filled points.

    The issue in two words, how to make it add 1 point every X seconds even when the user is offline. The solution i have in mind is making an array with the time stamps for each point. Which is a very strange and awkward attempt to resolve this task.

  • Thanks but I've kind of gave up on this idea for now, as i'm a beginner in php so i've decided to store my whole json in one column.

  • Lets say I have Stamina bar, whenever I press Attack button, it subducts the stamina variable by 1. The refill of stamina being performed by 1 every 2 minutes.

    What must be done to make it refill even when the user off-line?

  • Then, I guess, you should add another parameter to the php and to c2

    Example: if you add a parameter $string to php, make Data in c2 to: "L=" & UserLogin & "&S=" & UserPass & "&string=" & savestats.Text

    Thanks a lot! That kept me occupied for several hours.

    Here is how I solved it:

    Undefined index: has been resolved using isset:

    if(isset($_POST['L'])){
        $Login = $_POST['L'];
    
    }else {
        $Login = null;
    
    }
    
    if(isset($_POST['S'])){
        $PW = $_POST['S'];
    
    }else {
        $PW = null;
    
    }
    
    if(isset($_POST['D'])){
        $datum = $_POST['D'];
    
    }else {
        $datum = null;
    
    }
    [/code:1s003siu]
    
    and at construct 2 post I've used the following path on the basis of your suggestion:
    [code:1s003siu]"L=" & UserLogin & "&S=" & UserPass & "&D=" & savestats.Text[/code:1s003siu]
    
    Working like a charm!
  • It seems like what you're trying to do is sending data twice (two datas – first in URL field and another time in Data field).

    Try to do like this:

    URL: "http://localhost/legacy/save.php"

    Data: "L=" & UserLogin & "&S=" & UserPass"

    I'm not sure what's the savestats.Text inside the Data field.

    Thanks for reply, savestats.Text contains json string that must be inserted into the database.

    In other words, the place with $datum, must be provided with the string from savestats.Text

  • Hello, I've managed to make the Get with ajax to work, now i'm trying to Post some data and I'm getting errors.

    Here is how my php file looks like:

    header("Access-Control-Allow-Origin: *");
    
    $user = "root";
    $pass = "";
    
    $dbh = new PDO('mysql:host=localhost;dbname=dbname', $user, $pass);
    
    $Login = $_POST['L'];
    $PW = $_POST['S'];
    $datum = '{"c2array":true,"size":[3,10,1],"data":[[[0],[0],[0],[0],[0],[0],[0],[0],[0],[0]],[["Fatso"],[1000],[100],[900],[10],[10],[39],[10],[10],[0]],[[0],[0],[0],[0],[0],[0],[0],[0],[0],[0]]]}';
    
    $sql = $dbh->query("UPDATE registration SET data = '$datum' WHERE uemail = '$Login' AND upassword = '$PW'");[/code:dpqxiom2]
    
    Here is my construct 2 post request:
    [img="http://s33.postimg.org/7txzoq9gv/image.png"]
    
    At the debugger i'm getting:
    [code:dpqxiom2]Undefined index: L[/code:dpqxiom2]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply! I did that because if the burger isn't overlapping them, I want the burger to return to its starting position. However if it is overlapping them, then I want the burger to snap to them. Any ideas?

    Add all of the water containers to one family, then do the water containers overlaping the burger, set position to the water containers X and Y. And do the same with invert activated, in this case set position will be the initial burger position.

  • Here is the issue, you set the position everywhere to the starting Burger.StartX

    Edit:

    Here is a quick way of doing what you need.

    But the more easy way would be using the family feature.

  • There's a third party plugin that could help you, or you can use some javascript with the browser plugin or your own to parse it.

    I've tried the Json-to-C2-Array plug in but it throws errors from the start. I'll look into the parsing. That's bizarre that there is no simple way of doing it.

  • When construct 2 generates json file it is sligthtly different than the one that is being generated using php from mysql data:

    {
       ""c2array"":true,
       ""size"":[3,7,1],
       ""data"":[
          [[0],[0],[0], [0],[0],[0],[0]],
          [[1],[-1],[-1],[-1],[-1],[14],[26]],
          [[2],[30],[10],[8],[-1],[-1],[-1]],
       ]
    }[/code:16of4qpq]
    The above is example of json that construct tend to generate.
    
    Here is a json string that is being generated by my php file on the basis of mysql data:
    [code:16of4qpq]{"uemail":"mail","upassword":"password","data":"","level":"1000","nickname":"Rager"}[/code:16of4qpq]
    
    How I can load this type of information, from what I've read, construct 2 only understands the way it generates.
  • > like this?

    >

    Thanks I'll look into this one too

    I've looked into your file, thanks that was great. However, I've a question about it.

    What if I make a square1, add drag and drop to your square2. Whenever I put square 2 overlapping square 1, square 2 should rotate by 15 degrees and then keep on with the rotation taking into account the 15 degree offset

  • Using gamecorpstudio's example, click on the Flashlight, create a container and add the Lightbeam. Make two more copies of the Flashlight. Done!

    Thanks, that's what I've been looking for.

  • everytick = lightbeam.setangle-to:flashlight.angle that should solve it

    or you can use the pin behavior on light and pin it position&angle and will automatically follow the flashalight angle and position.

    here is a capx example v2 using pin

    i updated the toggle of the lightbeam now when you press the flashlight from button to the tail area it toggles the opacity of the lightbeam sprite.

    Thanks but I wanted to achieve something a bit different. As for now you have a flashlight and light beam, what I wanted is to use the same lightbeam on other copies of flashlight, like for example, If i copy the flashlight, set it to rotate by a bit different curve but use the same lightbeam on it. Such as, it moves differently, but light the same.

    And if you want to copy the flashlight and have the new one also have its own beam, use containers <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> https://www.scirra.com/manual/150/containers

    According to the manual this approach creates same object, but I can't manipulate each one of the created objects separately. I would like to animate the flashlight, or change its position independently of all other flashlights.