robit_studios's Recent Forum Activity

  • Is there a way to remove line breaks from a string in C2?

    For example: I'm importing text from a file using AJAX that looks like this:

    name1|001|Dialog 1|

    name1|002|Dialog 2|

    name2|001|Dialog 3|

    When it's saved to a string variable I want it to become this:

    name1|001|Dialog 1|name1|002|Dialog 2|name2|001|Dialog 3|

    I'm familiar with the "replace" system event but I don't know how to have it search for a linebreak. I tried newline and "/n" with no luck.

    Thanks.

  • I'm attempting the same thing. I have WAMPSERVER/localhost setup with a PHP file on it. I want to be able to access that file with AJAX in preview mode.

    I added "header('Access-Control-Allow-Origin: *');" to the index.php file on my localhost and I'm still unable to make it work. If I export the project and put it on my local server it works, but I don't want to have to do that every time I want to test the game.

    Any ideas on why this might not be working for me? Are there any browser settings I have to change, etc?

    Edit: This is the browser error I'm getting:

    XMLHttpRequest cannot load localhost/dialog_test/dialog.php. Origin localhost is not allowed by Access-Control-Allow-Origin.

    Edit 2: Figured it out. I had to add "header('Access-Control-Allow-Origin: *');" to the PHP file I wanted to access. It's working now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just wanted to verify that this issue has been resolved for me. Thanks Ashley!

  • Danijerry

    You are my hero. This worked like a charm. And I understand your method completely. I've implemented it in my game and it's working great. Thank you so much.

    Zetar

    Thank you for your help too. I love this forum!

  • Zetar

    Your method makes a lot of sense to me but I think there's a problem.

    <font size="2">System Compare Distance (Self.x,Self.y,ShipSprite.x, ShipSprite.y)<300</font>

    That line gives me an error saying you cannot refer to "self" in a system expression.

    The other problem is in line:

    <font size="2"> ->Set variable Self.AttackUID = ShipSprite.UID</font>

    I don't know how to set Self.Variable. I only know how to set a variable value for a specifically named sprite.

    I put together a capx that has a simple setup similar to what I have in my game. There is one ship sprite that can be 1 of 3 factions. When its in mode 0 it moves around randomly and when it's in mode 1 is moves towards the ship who's UID is stored in it's target variable. The ship is also in a family group called "enemy_ship". I'm using that family as a way to make the ship sprite differentiate itself from it's target. If you look at the code, hopefully you'll understand what I mean.

    http://dl.dropbox.com/u/28484936/target_ship.capx

    Danijerry Your method using another sprite sounds interesting as well, but my first attempt at it failed. If you have any other suggestion, or could take a look at my capx I'd appreciate it.

  • Here's a problem that I'm having trouble even beginning to implement.

    I use 1 sprite for all the enemy ships in my game. That 1 sprite has a variable called "faction" which can be 1-3. Depending on which faction it belongs to it'll change it's color and weapons, etc. If two enemy ships of different factions get close to each other I want them to target each other (in my case that requires a variable "target" to be set to the other ship's UID).

    I'm having trouble testing whether two objects, that are the same sprite- but are from different factions, are within a certain distance of each other. And if they are, changing each of their "target" variable to the other one's UID. This would be fairly simple if the two ships were completely different sprites, but there must be a fairly easy way to do it as I have it set up now.

    It kind of hurts my brain to think of how to make this work and I hope I've explained myself properly.

    Basically I'm trying to find a way to isolate 2 identical sprites that have different "faction" variables, compare their distance and if close enough set another variable, "target" to be the other sprites UID. Keep in mind that there may be as many as 50 of these sprites (of various factions) in the playfield at any time.

    Thanks.

  • Woops. I linked to the wrong capx file. This is the correct one: http://dl.dropbox.com/u/28484936/ship_shooter_animation_bug.capx

  • I found a bug in release R82 which makes my game unplayable. It appears that when a physics object has more than 1 frame of animation the physics completely breaks down. Here's a capx that shows the problem. You can press "T" to toggle the sprite between a 1 frame animation and a animation with more than 1 frame. Try moving the ship forward and then toggling on the animation to really see the problem.

    http://dl.dropbox.com/u/28484936/ship_shooter_animation_bug.capx

    Here are my specs:

    Windows Vista Home SP2

    64-bit

    GEForce GTX 560

    Chrome 17.0.963.79

    <font size="1">Edit: Corrected link to capx file.</font>

  • Jailson Did you ever have any luck with this? I'm also trying to destroy a distance joint at run-time.

  • Yann & R0J0hound

    Thank you both for your help. I've got my missile working just the way I want it to. I'm glad to hear part of my problem is a bug because I was beginning to go crazy trying to figure out what was wrong. Hope it'll be fixed soon.

  • R0J0hound

    I tried that and now I am getting the proper movement for the missile. But it causes a new problem. The missile is facing the direction that it's actually going, but I want it to always point away from the front of the ship, even though it's "global" movement may not be in that direction. I updated Yann's example and it shows pretty clearly what the issue is.

    http://dl.dropbox.com/u/28484936/ship_shooter.capx

  • Yann,

    Thank you so much for the help. Unfortunately it's still not behaving exactly the way I need it to. This only seems to work if the ship's angle is the same angle as it's velocity (in other words it's facing it's current direction of movement). But if the ship is facing a direction that is different than it's angle of movement the projectile doesn't behave properly.

    Imagine if you were driving a car in space (or a vacuum with no resistance) and you throw a tennis ball out of the side window. The tennis ball should move away from the car (at a 90 degree angle) but it also has the forward momentum of the car and no wind resistance. So while the ball is moving away from the side of the car it will also be moving in the same direction as the car. From the observer in the car it would look the same as if the car was stationary and he threw the tennis ball.

    That's the effect I want when the ship is moving in one direction, rotates his ship (but not changing his angle of movement) and fires a shot. The shot should move relative to velocity of the ship and away from whatever angle the ship is currently facing.

    Thanks again. Hope this helps explain what I'm looking for.

robit_studios's avatar

robit_studios

Early Adopter

Member since 17 Jan, 2012

Twitter
robit_studios has 1 followers

Connect with robit_studios

Trophy Case

  • 12-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies