JeremyBenson11's Recent Forum Activity

  • Hm, I don't know the best way... but you could have a variable attached to the object. Screentaps. Add one to it each time the screen is tapped... Every tick, when screenTaps = 2, set gravity to 0... or do whatever will make it fall.

  • I have some math that may help. You can set X Y through this equation. All you need is and angle and a distance. The rest is trigonometry.

    left arrow is pressed

    targetY = Sprite.X + d * cos(180)

    targetX = Sprite.Y + d * sin(180)

    down arrow is pressed

    targetY = Sprite.X + d * cos(90)

    targetX = Sprite.Y + d * sin(90)

    as you can see you are only changing the angle. If I were you I would save this. This will allow you to pick a point, from any sprite, move a sprite to it, or move that sprite to it.. Move ant sprite, any distance, in any direction.

    Swap d out for distance.

  • I'm just curious if someone could take the time to teach me a little math. I'm wondering what the best way is to pick a point from the sprite in any direction, a number of pixels away.

    I would think the best way would be by degree, but not sure how to do it. Like say I wanted to move the sprite 100px backwards, that would be 100 pixels at 180 degrees.

    Picture a sprite on the canvas, this has rays going in every direction that fits.. so how do I say, move 100px along this ray... or that ray? How do I get the x,y for that point?

  • Is it a regular square? 90 degrees wont show an effect, because a square will always be on its side.. but... if not, you do this...

    every click, or clicked on object, set angle to Sprite.Angle + 90

    Objects return data members through dot notation. If you type your sprite name and period, you'll see what can be returned... current angle, current x,y, some other stuff...

  • I know there's discussion on this. I already understand the fundamentals of serialization, but what are people using to create save-games in construct 2? I've read Ashley's article on the topic. I know about web storage, local storage, and slots... I'm just not sure which way to go, though. With the current options I don't like the idea of classic serialization and writing out every single data member by hand, why do that when there's other options? NW.js seems difficult with writing to files, and really only seems to be well suited for text. There's no real formatting options..

    The next best option would be local storage, which works like an ini, so at-least then you have keys to set and access. Slots seems easy and convenient. If slots were used in my case how much data is saved? Is it really everything other than what the docs mentioned wont be saved? So if the player saves in the middle of a level with badguys in certain positions, and all their data members set, will a load in that slot put everything in place? baddies where they were, and everything? Player will start right where they left off, as if on an emulator?

    This sounds like a good method to use in conjunction with save spots/save crystals, or whatever.

    The article also mentioned saving some meta data, not sure how to do this with NW.js, could the same be done with local storage, or would I have to use a set number of slots where it's key based.. That makes sense.

    Could someone give me a crash course on saving meta data with NW.js. This sounds tedious with nothing but text. Wouldn't I have to overwrite the file each time, serializing the same data, and have my own parse methods set up? sounds like a lot for infinite save slots... No wonder most fledgling games use a simple 3 slot system... lol

  • On your second layer all you did was:

    Set text to player coins, set player coins to player coins in local storage, and make a button.

    You didn't fetch the value at all, and set it to the text... try that in start of layout...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think the forums would benefit from a math section. Gamedev has one, and it's great. A good place to single out math related threads for people advancing in math to help better their game production.

  • If it is two players of the same type just attach another condition to the loop. A second for each loop that says foreach player if uid not = to the uid of the one you want to not destroy... Still, I can't see what you're doing.

    If you have two players that look the same, don't cut and paste, make two sprites, but for enemies it doesn't really matter. Should make your coding easier..

  • The only problem is if you're doing it against two players of the same type you'll have problems, because your player will always be inside the circle. This is why I would use separate sprites for player 1 and player 2, even if they look the same, you'll save yourself a lot of headache by separating their events and data..

  • I'm not sure I can help. Really need to see what's going on... too bad you couldn't post images yet, but you need certain reps to do that..

    Maybe if you explained it in clearer English.

    You have a player instantiated, and another object of the same type, just copy and pasted? And you have a circle that comes up around your player, and you want to test which enemies are in the circle? Find one enemy that's inside the circle?

    Attach an instance variables to your enemies. A Boolean set to false, called isInsidePlayerSight. Then add an event, every tick. Then add another condition, click the type your testing to overlap, and choose is overlapping another object, or oncollision with another object.. Click the circle.. then in the event click the object, set boolean value, turn isInsidePlayerSight to true... Then make a new event foreach of enemy. On the same event add a new condition choose enemy object, then find "is boolean instance variable set".. in that event do what you need to do to each enemy inside that circle.

  • This is something that was shared with me here.

    newX = enemyUnit.X + cos(random(360)) * random(100)

    newY enemyUnit.Y + sin(random(360)) * random(100)

    Say your enemy was picking a random point within a 100px radius from itself to move to. This is how you would do that... so maybe..

    newX = playerUnit.X + cos(random(360)) * random(100)

    newY playerUnit.Y + sin(random(360)) * random(100)

    would pick a random point up to this many px from the player..... You might have to play with the numbers though. This could put the enemy 1px away or 100px... you would adjust your range like random(50, 100).. Then they would pick a random point from 50 to 100 px away..

    You'll have to use another method if you want these points to be specific... not sure about that kind of math. Also you would have to implement a feature if you wanted the enemies to pick random points around the player that weren't the same... like test all previous checks in a while loop and pick a new location until they aren't the same..

    Not sure if this is a better way or not... One thing I do know. If you want your points to be picked cinematically this will not work.

  • Hm, to find a specific UID you use the event in the cog, for each. Select the object types to loop through, and you'll loop through each of that type. Then a sub event from that event, using the cog again, but this time choose compare two values. For the first value do sprite.UID then your comparison greater than, less than, and then your target value.. In that sub event destroy the sprite...

    Compare two values is very useful. You can use it for accessing dictionary keys with a specific value... Checking distance... all kinds of stuff.

JeremyBenson11's avatar

JeremyBenson11

Member since 24 Aug, 2015

None one is following JeremyBenson11 yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies