jsutton's Recent Forum Activity

  • My game has a chat area that contains text (from the array...name/text/variable).[array.at(0), array.at(1), and array.at(2)]

    If the variable is 1...then it creates a text box, adds the text and moves to the next set from the array [array.at(3),4,5...etc.]

    However, if the variable is 2 it creates a textbox and a sprite (for example, request defensive troops from other members of the game) If the variable is 3, creates textbox and sprite for whatever else I want...

    I'll check out loopindex...not played with that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I switched this up a little and used 50 functions (which is also not idea, but is way easier to follow the flow and takes about 1 second) since it allows the use of "else" statements for each array.x

    array.at(0) =1 then do abc (then run next function)

    else array.at(0)=2 then do xyz (then run next function)

    array.at(1) =1 then do abc (then run next function)

    else array.at(1)=2 then do xyz (then run next function)

    Still looking for alternatives, any thoughts are greatly appreciated.

  • I learned arrays by playing around.

    Make a new .capx and test this out.

    Add array, touch, sprite1, sprite2.

    Make your array 3,1,1

    Event Sheet

    On start of layout:

    set value of x 0 to 100 (array, set at x)

    set value of x 1 to 400

    set value of x 2 to 200

    on touch sprite1: sort array

    on touch sprite2: reverse array

    Then run this in debugger preview (that way you can see how the array changes as you click)

    Good Luck

  • Curious if there is another option to using a massive number of sub-events.

    Import 150 items into an array via AJAX, then want to order them. (this is for a chat screen that allows for sprites etc to be inserted/created in chat log)

    Currently:

    Event...Function - On "X"

    Sub-Event...Array - value.at(0)=xyz then create textbox at (1,1)

    Action...set textbox width 500, set textbox height to textbox.height (allows grow/shrink textbox height to match text)

    Sub-Sub Event...Array - value.at(1)=abc then create textbox at (1,textbox.height+10) (allows next textbox to be created just below the first textbox)

    The problem is the last sub-sub event will be 148 recessed (bad wording probably, indented?).

    Just curious if anyone has a thought on a better solution...if not no worries, this does work it just looks ugly and is hard to follow.

    Thanks

  • Posting this since I spend 3 hours on this silliness and thought I'd help someone else if it ever comes up again.

    #1 Have .php file, works fine in browsers.

    #2 Have AJAX on send...tag, data, post...updates the database.

    ***Everything works and yet...still triggers Error*** (error in construct and not triggering next events*)

    Could find nothing on C2 forums that helped figure it out...(didn't know what the problem was, so hard to find a solution)

    Finally I went to the browser developer tools to see if anything was there.

    On Mozilla: Developer, Console

    Scrolled down to see:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.***etc., etc.com?call=1234 (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

    After 5 minutes...the "L"s in Allow were "1"s... (no clue how that happened on a copy/paste), hope this might help others to self identify AJAX issues.

  • Call this one closed. I'm using sprites in multiple families and loading data from arrays and hard code. I tried to recreate the issue to no avail, so it's in my code (seems the most obvious reason anyway).

    I changed family variable from one family to another and it works fine...don't know why, atm it works fine so don't really care. Moving on lol.

  • Formula (var.a/var.b)*var.c

    All are instance variables are from different sprites.

    All show to have no decimals in debugger.

    var.a =5

    var.b=375

    var.c=100

    (5/375)*100=1.333333333

    *** In debugger the number returned is 1 *** Should be 1.333333333 ***

    I do not have a floor or a round used on any of these numbers and the value returned makes zero sense to me.

    Any thoughts?

  • gumshoe, thanks for your response!...turns out I'm just a moron!!!!!! sigh...

    I just happened to test a blank user name on the database to see if i could pass all the data and only half passed...turns out that when I switched layers it was deleting my sprite and creating a new one with empty variables (needed to update the database). Fixed that and it works fine.

    Basically I learned, if the php is working on URL it should work fine with construct.

    Case closed.

  • To begin i have watched Arcade Ed's videos (thanks Ed!). I can INSERT INTO without issue, echo, and pull info into an array without issue.

    my issue, and I've been stumped for the past 2 days...

    on the php side:

    $a = strip_tags(mysql_real_escape_string($_GET['a']));

    $b= strip_tags(mysql_real_escape_string($_GET['b']));

    $sql = mysql_query("UPDATE table SET a = '$a' WHERE b = '$b'");

    if i go to the browser and change a or b it loads into the database fine, for example:

    http://localhost:8080/doa/bc.php?a=6kala8sh9aaahdhf163s;76;h9dkf1kjkakfdffjj9jafk677f144&b=Bob

    (easily changes by:

    http://localhost:8080/doa/bc.php?a=fjkdlssdlkfslk&b=Tim

    REPEATING: BC.PHP WORKS FINE FROM CHROME BROWSER

    however, when i use construct to send an ajax "POST"...

    "http://localhost:8080/doa/bc.php?a="&Account.ID&"&b="&Account.Username

    nothing happens. It's the exact same code, so I have no clue why this isn't working.

    Oddly enough, I can easily change bc.php to INSERT INTO and it works fine from construct but it creates a new row [due to auto increment] or overwrites my existing fields (which I don't want to happen)...any thoughts?

  • I have the same issue...can pass text all day, but not global variable set to text.

  • Not anything I've messed withthis , but if I understand your problem...defining the other sprite as an obstacle and refreshing around each every x seconds should work...or so I would think. Both sprites much be obstacles respectively. I've been running multiple copies of the same sprite and defining hits on overlap...works fine and kinda the same issue. Just havta be careful not to refresh the whole thing each time or you'll run at negative fps lol

  • Couldn't u define the obstacles for each sprite?

jsutton's avatar

jsutton

Member since 31 Mar, 2015

Twitter
jsutton has 1 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • RTFM Read the fabulous manual
  • Email Verified

Progress

12/44
How to earn trophies