Sam Mortimer's Forum Posts

  • I'm trying to randomly generate people that spawn every now and then and walk around. They're made of a torso which contains all the important instance variables and a bunch of other sprites hanging off (limbs, facial features) in their own family called 'BodyParts' or something.

    The characters will be moving around, changing size (handled with a 'SizeScale' instance variable rather than the built-in 'Scale' parameter which wasn't really doing what I'd hoped), changing the z order and jumping between layers.

    I think containers might be what I need, but I don't quite understand how they work so instead I've given everything an 'index' instance variable to show which body parts belong to which torso. I've been using this with the conditions 'if BodyParts.Index=Torso.Index and Torso.Index=BodyParts.Index', to make sure the right instances get picked. Then I'll move the sprites to where they need to be or whatever.

    Anyway, it's not working. The way it assigns the index works fine, the z ordering fake-3d stuff works fine with just the torsos, but the other body parts are all over the place. Even when the conditions specify I want to pick the BodyParts with the same Index as a Torso and visa-versa, it just isn't happening. Some body parts behave and move with their parent torso, but most of them just float about ignoring the programming.

    The BodyParts definitely have the same 'index' as their corresponding torso. So how do I get the conditions to pick all the right ones? Alternatively, is their some other method of getting different objects to move around like one object, including their Z order and everything?

    Sorry if I'm not explaining this properly or if I'm missing something obvious.

  • Oh hey look at that, it works beautifully. Thank you!!!!

  • I'm making a little system for highlighting interactive objects close to the player in this platformer/adventure-game thing. It uses a big invisible circle over the player that acts as the area in which interactive parts of the environment can be interacted with. So, if an object in the 'Interactive' family overlaps this big circle AND it's the nearest instance to the player's position, it is highlighted with a boolean instance variable thing going 'true' and with a little visual effect.

    SO how do I then un-highlight an object? The easy part is un-highlighting anything not overlapping the player's magic invisible interactive circle. But I also want to pick all instances in the 'Interactive' family which are overlapping the circle but ARE NOT the closest instance to the player.

    I need to pick all instances which do not fit the condition "pick closest to player". How do I do this???

  • thanks a bunch.

    • Putting all my events in groups and only enabling each group when I need to, otherwise they're left disabled so the game doesn't have to think about them.
    • Adding 'Every X seconds' beneath conditions that would otherwise check every tick.
  • I don't know if this is actually what you'd call 'masking', but what I want to do is have every object on one layer display what's on another.

    So, there would be one layer called 'Objects' with various rectangle sprites scattered around it, then another layer called 'Texture' which contains different moving shapes. Not sure how to phrase it, but I want everything on Objects to have the appearance of the Texture layer. The Texture layer is only visible where stuff is present on the Objects layer.

    I guess you'd say I want Objects to 'mask' Texture?

    What blend mode & other settings should I apply to each layer and what order should they be in?

  • Oh right. Have you tried 'choose()'? It randomly picks one of the values between the brackets, e.g. choose("Yes","No","Maybe") could give 'Yes', 'No' or 'Maybe'.

  • Say you wanted the player to always be in the centre of the screen. Instead of giving the player the ScrollTo behaviour, I would give the behaviour to a separate object called Camera with an instance variable called something like 'ShakeY'. Every tick, set Camera position to Player.X,Player.Y+Camera.ShakeY. When you want to shake vertically, some how or other set the value of ShakeY to something random and crazy a few times then reset it back to 0. Easy!

  • In debug mode, not all the audio that's playing is actually listed under Audio. Construct 2 doesn't seem to realise that the tags "1a" and "1e" are playing at all, which would explain why it can't sync them up. So, why can't Construct 2 keep track of what is and isn't playing? How can I fix/compensate for this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well for a random value, use random(x) for a number from 0 to x, or use random(x,y) for a number from x to y.

    I have no idea about high scores and stuff.

  • My little dynamic soundtrack thing I'm doing needs the looping sounds "1a" and "1e" to always be in sync.

    1e will begin while 1a is already playing. When 1e starts, the tag seeks to Audio.PlaybackTime("1a") seconds.

    Then for good measure, if Audio.PlaybackTime("1e") doesn't equal Audio.PlaybackTime("1a"), seek "1e" to Audio.PlaybackTime("1a").

    For some reason this doesn't take effect until I click outside of the window (freezing the game) then click back in, at which point 1e will immediately jump to where it's supposed to be.

    What the hell could be causing this issue? It's making the music sound atrocious. Please help!

  • Thanks for the help!

  • Does 'for each' mean 'Repeat this action on every single instance of the object' or 'Repeat this action for every instance of the object that fits the conditions'?

  • What the fuck. How have I never noticed this 'for each' thing? This makes everything ever so much easier. Jesus christ.

  • The character limit makes it a bit hard to explain my problem in the topic heading.

    I'm making an endless-runnner with a car object that you run past from time to time. Basically I want each instance of the car to play a looping sound that starts when the car is first on-screen, becomes louder based on how close Car.x is to scrollx, and stops when the car is no longer on screen. The sound must also be muted and unmuted based on the local value 'sound'.

    I've given the Car object a boolean value called 'IsPlayingSound'. If the boolean value is false and the Car is on-screen and the local value 'sound' = 1, then the sound 'Car' is played looping with the tag "Car"&Car.uid.

    If the local value 'sound' = 0 (so that the player can mute the sound if it's annoying them) and 'IsPlayingSound' is true, then the boolean is set to false and the tag "Car"&Car.uid is stopped.

    If Car is not on-screen and 'IsPlayingSound' is true then set it to false and stop "Car"&Car.uid.

    And finally, if Car is on-screen and 'IsPlayingSound' is true then set the volume of "Car"&Car.uid to a little maths equation that makes it louder when Car.x is closer to scrollx.

    It all works surprisingly well, apart from when I try to stop the car sound if the local value 'sound' =0. The value can be toggled between 1 and 0 by pressing N so that the sound can be muted by the player.

    This works when one car is on-screen, however when more than one car is on-screen then only one of them has the sound stopped while the others continue to play.

    I'm sure that this shouldn't happen. If I've written If 'sound' = 0 and Car IsPlayingSound, then set IsPlayingSound to false and stop tag "Car"&Car.uid then surely it should affect every car? It should go through each car which 'isPlayingSound' one by one and set the boolean to false and stop the sound, right?

    I could easily solve this problem if sounds could have multiple tags. Every sound would have two tags, "Car"&Car.UID and just "Car". That way I could start, stop and control the volume of each sound using "Car"&Car.UID and I could mute/unmute every sound when the player presses N using "Car".

    Except I can't do that be because obviously Construct 2 doesn't support multiple audio tags. So, does anybody know an alternative solution?