JeremyBenson11's Forum Posts

  • Moving to a mouse click is easy. You can create instance variables. mouseX, and mouseY on the player. When the mouse is clicked you can set those values to Mouse.X, and Mouse.Y. Then you can create an event that will move the player to that position.

    Make sure the mouse object is in the layout..

    If you don't mind if they lerp there then:

    set position event

    in the x box

    lerp(player.X, player.mouseX, 1 - 0.5 ^ dt)

    in the y box

    lerp(player.Y, player.mouseY, 1 - 0.5 ^ dt)

    The mouse icon would be pretty easy too.

    for the event you would do the cog wheel compare two values distance(player.X, player.Y, mouse.X, mouse.Y) <= x

    set cursor to this image.. then you do another event for the second image.

    X in this instance is replaced by the distance in pixels.

    If you want the player to move fast when clicking far away... you can do an event.. if distance from

    player.mouseX, player.mouseY > x

    then lerp(player.X, player.mouseX, 1 - 0.3 ^ dt) -- see here 0.5 became 0.3, which is a quicker speed.

    Do the same for setting player Y...

    that number can't be greater than of equal to 1... so 0.1 - 0.9 the lower the number the faster the lerp... if you find lerp isn't working for you there is LiteTween, which is a custom plugin you can get here:

    It's like lerp, but a little more to it..

    Please forgive if the math is a little off, but I think this will work, and a good starting point to experiment with in the least..

  • wow, if that sends a message to Google, or some other place, I have no idea... Does that connect to some kind of API, or do you just need to get permission? If you just need permission you wouldn't need this. All you would have to do is have your first layout be the policy. If they accept send their username and message to the database saying they accepted the policy, then show them the game... if they click no... show them the game, without the ads, or without what they say you can't show without permission. If nothing send them to a layout that says, "sorry, can't play without permission." Then an ok button.. have the ok button go back to the permission collection layout.

    It really depends on if that code above communicates through an API to an external site...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm gonna be honest, but in-case those who have helped me are reading, this doesn't apply to those who have responded to my posts... Those guys are cool, and helped solve every problem... but this forum is, or at least my first impression after a couple of days posting, was that this forum is NOT the most helpful on the web. Trust me, there are other forums that will get 8 posts a thread, and people are eager to help. This is not that kind of place. I had several threads sink to the bottom, before I ever got a reply. I seen people with four bumps through a couple of days... but... I did eventually start getting replies... also, you could help others while you're waiting. People will notice that you're helping, even if it's a small amount... you're in general topic right now, make some friends by talking about your favorite game, or the weather... if you know something, add it as a tutorial... People will notice you and help you... but.. if you're lazy... like Prominent says, this is just the way the forum works here... some get answered, some don't...

  • But if I use web storage, this NW.js right? Wouldn't I need to set up my own method of separating the json strings? There would be some kind of delimiter? Then how do I read in the string, and use the delimiter to break them back and put them in my objects? That's kind of what I'm wondering. I don't really understand how to do it through Construct. It's not really the same as using other languages, with knowledge of how the events flow..

    Would it be easier to serialize by json strings into keys, and use local storage? What method works best for broad range of devices?

    Thanks for your reply,

    Jeremy.

  • Cool, thanks to both I finally have all the math needed for basic movement.

    Discovered how to move an object a number of px in any direction..

    How to move object up to a certain random number of px from itself..

    Now I just need to figure out custom movements, like following an arc, or what have you.. Have no idea where to start with that..

  • No problem, glad it helped

  • 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...

  • 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..