Colludium's Forum Posts

  • There are many different ways you could do this and it's probably worth checking through the FAQ and doing a forum search to see how other people would solve this.

    For me, I would give my enemy a Boolean variable WalkingRight and put a couple of invisible obstacles on the layout where I want the enemy to change direction. I would give my obstacles each a Boolean variable as well, something like ChangeToWalkLeft - the obstacle on the right would then have this set to true and the one on the left set to false (this prevents double collisions giving you problems later).

    Then in the event sheet, the enemy controls would be:

    • if enemy.WalkingRight = true ; simulate platform press right
    • if enemy.WalkingRight = false ; simulate platform press left

    -> On enemy collision with obstacle

    ---> if obstacle.ChangeToWalkLeft = true ; enemy.WalkingRight = false

    ---> if obstacle.ChangeToWalkLeft = false ; enemy.WalkingRight = true

    I hope my text version of the events you need makes sense...

    Have a look through the FAQ as I said at the start, there are some great examples of how to do all sorts of things with C2. Enough to take up your whole weekend... <img src="smileys/smiley1.gif" border="0" align="middle">

  • Thanks AllanR for the help. Although I'm a novice at time stamps, it would appear that the plugin could enable me to provide even more advanced features on my app in future (so that duty hours could be tracked over a rolling 7 day period for example - something for the next but one update I think!). Just for interest, my solution to this data crunching: I've decided to convert the input values using a common denominator so that minutes and decimal (1/100th) hours can be converted to/from each other without the answers resulting in those pesky floats. It's quite simple now I think about it... <img src="smileys/smiley1.gif" border="0" align="middle" />

  • I'm going to call this closed because I've had the help I needed to get things moving forward.

    RamPackWobble - thanks for the examples. It's going to take my slow brain a while to understand the maths behind test 1 but it works a treat.

    AllanR - I'm downloading the plugin now - thanks for the tip, it might just do the job.

  • RamPackWobble and AllanR,

    Thank you both for your advice. I particularly appreciate the capx examples. I'll have a look at them today and let you know if they work for me - although I think your first point was excellent because it gave me some clarity on the issue... I seem to have become wrapped up in trying to solve a technical challenge rather than finding a workable solution to my update problem. I don't have time to look at the examples at the moment (day job in the way of fun) but I think I'm going to try to convert my time to minutes and store that data - that way there'll not be any floating point nonsense!

  • Dear community,

    I'm hoping that someone out there might be able to help me solve a problem I've been battling for the past couple of days. I'm trying to update my app for android and ios (link to google play) but I've hit the limit of my understanding of how computers do maths... The app is not a game, it's a time calculator (ie it does base 60 maths for hours and minutes addition and subtraction) and I'm trying to update it to offer decimal hours as an input option. So now I want it to be able to add floating point variables and convert said fractions into hours and minutes (using simple code if possible!).

    Presently the data is stored in arrays for hours and minutes and I'm sure I could fudge the current event sheet to make it work - but the OCD parts of my brain want to make the new version look neat and tidy.

    The problem is that when using floating point variables, the 'int', 'abs', "%" and other mathematical system expressions aren't reliable for my needs. C2 seems to round variables depending on their context and I'm stuck. Is there a simple and reliable way to convert a number such that the whole number can be displayed in base 10 and the decimal fraction can be converted to base 60... a way that will also work with negative numbers?

    Let me elaborate. Subtracting int(N) from N doesn't always give the decimal fraction that remains - see this capx to demonstrate what I mean.

    Does this mean that I'm going to have to convert my data into text strings and then manipulate the string to get the answers I want, or can someone think of another way...? If I need to I will, but I'm hoping for an elegant solution...

    I've tried following this thread's advice but it doesn't work for me, especially regarding negative numbers:

    scirra.com/forum/format-to-2-decimal-places_topic57060.html

    Thanks for reading this far!

    I know, C2 is meant to build games... I couldn't help myself!

  • An alternative could be to use a global variable MouseButtonTimeDown:

    Condition:

    Mouse Button is down

    Trigger once while true

    Action:

    MouseButtonTimeDown = time

    Then have another condition checking for MouseButtonTimeDown > whatever cutoff time you want for subsequent actions.

  • Could you post a link to a capx example?

  • They are all object variables inside the Sprite object. So with the event system you could manage lots of different instances all using the same handful of events.

    Edit - glad you got it - I'm too slow at typing again!!

  • When I do this sort of thing I put the physics parameters into object variables. Then, when it's time to resume, I just put them back into the object's physics parameters. Something like this should work if I understood your question fully:

    <img src="https://dl.dropboxusercontent.com/u/184657779/C2_demos/physicsOnOffParametersSave.png" border="0" />

  • fishbottle (& R0J0hound), funnily enough I have just reverted back to using the Canvas plugin for something I'm testing through CocoonJS. I had a selection of Paster tiles covering the ground onto which I was pasting battle scars and other visual effects. There were about 100 tiles... Initially all went well with my testing then something happened - I presume I exceeded a memory threshold or something by adding a sprite (~50mb was being used on desktop according to debug, unfortunately my testing was too infrequent to be able to identify what it was that I changed to cause this).

    All of the blank canvas tiles appeared corrupted with pasted parts of random image files (some from my game and others from apps that were installed but not running on my phone!). I would be very interested if anyone else has had this experience (I tested on 3 different android devices with the same problem evident on each).

  • If you're looking to test that a specific key is not down then I would do as stated above.

    If you're looking to test that no keys are being pressed then that's not quite as straight-forward. This is all I could think of - I hope it works for you.

    <img src="https://dl.dropboxusercontent.com/u/184657779/C2_demos/keynotdowntestusingkeycode.png" border="0" />

  • Only subtract whole numbers from your Ammo_Total global variable. Then have an every tick sub-event somewhere convenient:

    If Ammo_Total < 0 then Ammo_Total = 0.

    Edit - I see I'm too slow at typing again...!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • RamPackWobble,

    Err - no! My mistake - it appears that I need to go back to the manual (again!!). I have also encountered OrangeFlash81 's problem before and just assumed that this was the case (a system create object never causes the non-setting of attributes as shown in the OP).

  • OrangeFlash81,

    Just so you understand why your method didn't work: when you use a spawn, the spawning object's attributes are inherited by the created object. This includes the object's angle (so, on your example, I'm guessing that the Boombox was set at 90 degrees for all of the bullets to travel downwards). This spawn action overrides any immediately subsequent attempts to change these inherited attributes. Son any attempt to change an angle after a spawn will never work.

    A crazy alternative method would be to create 8 invisible gun objects and pin them to the player, with each one set at 45 deg to the last. Then, when you shoot, you just have one line commanding "gun: spawn bullet" - the event system will select all guns and spawn all of the bullets for you.

    Hope this helps!

  • AnD4D,

    Does this work for you? It sets the physics rotation speed according to the angle difference between the mouse position and the sprite angle:

    capx