AllanR's Forum Posts

  • dop's file has an example of how to connect to a value - when you click the button, it sets the slider value to 10.

    but that could just as easily be Created_Objects.HSL_Value, or anything else...

    using image points is the easiest way to limit the knob to where you want,

    or you could adjust the clamp values like this:

    knob - set X to clamp(self.X, Slider.X +5, Slider.X + Slider.Width -5) (see below)

    (and then change the +5 / -5 values until you get what you want - Dop's example has the image points at +8 and -10)

  • if you are using a text object in C3, those a are rendered directly on the canvas by C3. They do not use CSS to define their appearance.

    if you are using Textbox and buttons, then those can be styled by CSS.

    another option is SpriteFont - which as the name implies, uses sprites to make up the text you want... so that may be a way to achieve the look you want.

  • that looks awesome! :) you should add a few particles to make it look like the buildings are crumbling as they get destroyed. And post the capx so people can see exactly how you did it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yeah dop's file uses image points, lerp and unlerp to position the knob - which is a very clean, concise way to do it. (Really nice example dop!)

    The way you are trying to do it will also work, but you need to include the slider's x position as well as the width.

    the lower clamp value should just be Slider.X

    the upper clamp value will be Slider.X + Slider.Width

    so the full clamp expression will be:

    Knob - set X to clamp(self.X, Slider.X, Slider.X + Slider.Width)

  • you may need to enable bullet behavior in event 54 (if you disabled it by default to keep the ship from flying off the screen at the beginning).

  • it all depends on what you are doing with the array.

    I just added a 25,000 cell array to an old tetris game I made ages ago. and set every cell to a random value at the start of layout. that made no noticeable difference on my computer or ipad.

    then looping through every single cell once a second checking to see how many cells were greater than a random number only slightly affected performance. My computer went from 60 fps to 57. My ipad went down to 55 fps. I could only tell the difference because debug mode said the fps was a little lower.

    looping through every cell every tick made it feel a little sluggish - down to 30 fps. but was totally playable. So I tried again with a 50,000 cell array (loop through every tick). The pieces fell very slowly, was getting 16 fps. The pieces rotated and moved fine - just went down the screen very slowly, so it is more of an issue of not using dt properly...

    saving a few values at the end of a level, and restoring those when you come back should be no problem. But, again, it depends what you are doing with the array, and what else is going on - how many moving objects, effects, etc.

  • your english is very good. I have helped people on the forums for years because it is a great way to learn and try out different solutions to interesting problems.

    "1 - Is there a simple solution: if the instance is REALLY close to one of the edges?"

    is there ever really a simple solution? :) you know the width and height of the panel, so yes, you can use those values to tell if it is on the screen or not. The tick is where to move it so as to not cover up the object you are trying to modify... I tested to see if "Bound to Layout" would work, but there is no way to disable that when you want to hide the panel. So that means you would have to destroy it and recreate it every time. So, it is probably easier to just calculate where to put it...

    2 - save size

    I think you will be ok, but you will want to test that out at some point. I suspect that you could add a couple thousand objects before size will become a problem. but that is just a guess.

  • the "every tick" on stage 2 does not have any effect - as long as stage is 2, the actions on that event will happen every tick until stage is no longer 2.

    the same goes for stages 1 3 4 and 5 - they will also run every tick when stage has one of those values, unless you add a "trigger once" or change the value of stage.

    in your original post you said you want the character to not be walking at the start - but how can the character not be walking if you only have a walking animation?

  • I gave it a try - as usual, there are quite a few tricky things to get right!

    thanks to rokstars322, I was able to edit your sample by deleting one of the effects from the Created_Objects family - since I don't have a C3 license yet either. All the code is there, so you can just add the Contrast effect back in to make it work...

    your disabled code was not working because you were checking for a click on Created_Objects, Selecting the object, then the next event was undoing it (because the mouse click was still true, and now there was a selected object to unselect).

    so I re-structured that whole section... (I also deleted the fullscreen code because it was running every tick and making my screen flicker)

    Having a Control Panel adds a whole new level of complexity and new problems to the logic of an object family. If the panel is over an object, any click on the panel may also register as a click on any objects below. In your case, that would cause your code to mysteriously change selected objects without you knowing why. AND if there isn't an object under the panel, then the code would think you are trying to un-select objects! (which would also cause the panel to disappear!)

    the solution I have used to fix these issues in the past is to have an object be part of the family and use it as a shield. So, I made a Panel_Shield sprite, set it to be invisible, and made it the same size as the panel, and pinned it to the panel. When ever the panel is brought on the screen, the panel_shield must be moved to the top of the layer because if there are any objects above it, you will have trouble. (or keep it on the UI layer - I had to delete layers because of free version limitations).

    the panel_shield is given a unique "ObjectType" so that we know to ignore clicks on it. It is also important to always use "Pick Top Instance" when doing any mouse button events so that the shield properly blocks clicks from objects we didn't mean to click.

    rokstars322 showed updating the Created_Objects when the slider "On Changed" trigger fired. that only updates the value when the slider is released. So, I followed your code where the value is updated every tick so the user can instantly see the effect.

    and, like Dop said, you need to store the values in instance variables in the family...

    https://www.rieperts.com/games/forum/effects.c3p

  • the art looks great.

    do you have idle animations? you could just stop running the animation when it gets to its target, but it would look better to have an idle animation.

    I am not really clear on what you have in the array? just the animation name? you could add extra columns for different animations:

    Array_Player_Full.At(Player_Select,0) for idle

    Array_Player_Full.At(Player_Select,1) for walk

    Array_Player_Full.At(Player_Select,2) for run

    Array_Player_Full.At(Player_Select,3) for Attack, etc...

    or skip the array, and set Player_Select to the character type (Warrior, Ninja, Wizard, or Knight) and then set animations as you need like this:

    Set Animation to Player_Select & "_Idle"

    or Set Animation to Player_Select & "_Walk"

    in events 11 to 15 I see you checking Stage and starting to move the character to a destination, but I don't see you updating Stage. That means those events will happen every tick. Once a sequence has been started, you should update Stage, or add a trigger once. then when the sequence finishes, set animation to Player_Select & "_Idle"

  • in event 6, just add some time to ShootSpaceship.

    if you want the spaceship to shoot 10 times a second, set ShootSpaceship to 0.1

    for 5 times per second, set ShootSpaceship to 0.2

    for 3 times per second, 0.33

    twice a second, 0.5

  • I have used much bigger arrays without any problem.

    I read somewhere that javascript uses an average of 9.7 bytes per cell, so a 24,000 cell array would use less than 240K of memory. You could quadruple the size and still be under a megabyte.

    graphics take up way more space!

    brunopalermo's suggestion is good, and would be slightly quicker to search through, but I doubt you would actually see any difference.

  • check out this thread too:

    https://www.construct.net/en/forum/construct-2/general-discussion-17/trajectory-arrow-118686?kws=angry_birds.capx

    I have a couple samples on there that shows a trajectory in an angry birds type game. The one that uses Chipmunk physics is a better version (but requires the chipmunk plugin).

  • like plinky said, the Set Item was in a bad place - that whole group was running every tick - 60 times a second, continuously resetting the buttons... and there were a lot of other bugs and issues.

    you can't know what the MaxLevelWon is until after the array is loaded from local storage.

    the State variable on the LevelSprite was not really necessary since the second column of the array was being used to tracking whether a level was locked or not. So, I simplified things a bit.

    the SaveEvent even sheet wasn't very useful - and definitely not needed on each level layout (so I removed it). Once the array is loaded from local storage, it is global (you don't need to load it again when a level starts). The proper time to save the array to local storage is when a level is complete.

    I made a number of other minor improvements, plus added at button to reset progress (delete the local storage item) for testing purposes...

    https://www.rieperts.com/games/forum/levels.c3p

    I wouldn't say this was extremely simple. Arrays give lots of people trouble, and so does local storage. I have seen tutorials on how to lock and unlock levels that didn't actually work and gave people really bad advice!

  • I am not a 100% sure, but that seems to want to return either true or false - not one of the values you want.

    I would use

    Set GotoX to choose(Cruiser.X+random(20,40),Cruiser.X-random(20,40))

    Set GotoY to choose(Cruiser.Y+random(20,40),Cruiser.Y-random(20,40))