AllanR's Forum Posts

  • not sure if this will help or not...

    for a lot of the database work I do I resize the canvas to the window dimensions so that I get a 1 to 1 pixel size. That way one pixel wide lines don't scale / get blurry.

    So, I tried similar logic to limit the canvas size. My sample project below turns off scaling, and just resizes the canvas based on the window size. I clamp the values to limit how big (and how small) the canvas can get, and re-position objects as necessary.

    I create a red dot on each touch to show that the touch coordinates are correct. If the window gets too big, the canvas size is limited - which results in a black bar on the right and/or bottom. (not sure if the canvas can be centered). C3 still recognises touches outside the canvas area, so I filter those out...

    I have no idea if this will affect performance the way you hope.

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

  • by rare cases I meant the rare time I want to have a touch apply to multiple instances and still have it stop at a certain point.

    I agree that 99% of the time you probably just want the top instance, but it only takes one extra condition to accomplish that (Pick top instance).

    here is a sample based on the drop shadow file I made yesterday. I added my touch tracker and SpriteButtons family to show how I handle picking the top instance, using a shield to prevent clicks, multi-touch and a variety of other situations.

    you will notice that if you arrange a window to partially cover the close button of another window that the close button only goes into the Hover state if the mouse is not over the higher window. And the window blocks the drag bar and any other buttons on windows below. Multi-touch is handled properly too, only one touch can select any individual button, you can hold down one button while using others, if one touch causes another button being touched to be destroyed it doesn't freak out, etc.

    The sample also uses Font Awesome web font icons just for fun.

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

  • if you are using a family, you can identify the sprite name with family.ObjectTypeName

    however, I think the issue is minification. Picking a sprite by .ObjectTypeName will work, but if you are comparing to a literal string, that might not work after minification... haven't tested it.

    I like the fact that C3 lets me decide how touches work / which instance a touch applies to. I like buttons to only execute after the touch is released. So I track all touches with an invisible sprite that tracks where the touch started, where it ends, how long it has been in touch, etc. My touch sprite tracker does have a boolean called StopClick just for rare cases like you mentioned...

  • are you using SSL? you browser will block access if it is not secure. You can press f12 to get to devtools and check for errors...

  • I keep all my touchable objects in a family, then on touch "Pick top instance" filters out all instances below the top one.

    all of the touchable objects also have an instance variable saying which function to call when they are touched. So one place handles all the touch / multi-touch logic, then when it is determined what was touched it branches to the function that handles what happens from there.

    if I want a button or group of buttons to be modal (so that nothing else on the screen can be touched), I use an invisible object called ButtonShield that is part of the family and expands to cover whatever area I want, but has a blank function variable and it goes just under the active buttons in z-order. (since I always use pick top instance, this blocks any other objects below the shield)

    there are a bunch of other tricks to make a user friendly, proper multi-touch, intuitive UI. It is harder than you would think, but C3 gives you all the tools to make it work exactly as you want.

  • you should only need one array to do what you are describing, each row in the array can hold multiple values

    first entry:

    array(0,0) = x value, array(0,1) = y value, array(0,2) = Position

    second entry:

    array(1,0) = x value, array(1,1) = y value, array(1,2) = Position

    you would define the array size as (#entries,3,1)

    however, if you know you have a 6 x 6 grid, it should be pretty easy to calculate the x and y values when the position number is 1, unless I don't understand what you have in mind.

    it would help if you made a mock up of what the final screen would look like, the 6 x 6 grid, and safe path for the player to follow.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • this is what I do for UI element shadows - use a seamless 9patch shadow png (so it can be scaled to any width/height without distortion).

    since it is pre-rendered, there is no blur performance hit. Obviously this only works with rectangular objects. This demo creates 10 random shapes with a shadow - the shadow has a fixed offset but the opacity is random. The objects have drag and drop so you can move them around...

    In the top left corner I included a white version of the shadow png so that it can be coloured, but I normally only use black shadows.

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

  • I gave it a quick shot too... I made it like a joystick, so it auto selects the center position unless you are pressing a key. I prefer arrow keys so I used those. I don't have a gamepad to test with so it is keyboard only.

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

  • your code will try to mute the sounds every tick - as long as the boolean is false.

    there could be other places in your code that are running every tick that are undoing the mute on certain sounds.

  • in event 7, where you add child ButtonText, you are not picking one instance of ButtonText so ALL instances are being added as a child to Button, and then they are all getting the same properties.

    If Button was a container, then each Button would have its own instance of ButtonText (but families can't be a container). So, you can create an instance of ButtonText for each Button, or if they are already on the Layout, pick the nearest instance or use some other way to associate a ButtonText with the appropriate Button (and pick just that one instance).

  • I would give the PlacementLocation an instance variable "Filled" or "Planted" and set that when you plant something. Then before planting anything else check if that it set. Clear it when you harvest.

  • in your previous post, you are checking CornCrops Overlapping CornCrops. That should be CornCrops overlapping PlacementLocation

    I would place the code to set the Animation frame in the event that increments the growth variable since that only runs every second. The way you are doing it will work fine, but it has to calculate the frame every tick (60 times a second) and it wont be changing that often. The less unnecessary work you do, the faster your game will run (and use less battery if you are aiming for mobile).

  • you will probably want to add a TimePlanted instance variable, or maybe a countdown variable until the plant is full grown...

  • you have the PlacementLocation and CornPlant2 reversed in the final event where you want to destroy the CornPlant2 instance.

    the way you have the event condition makes it "pick" PlacementLocation instances, but you want to pick CornPlant2 instances. So your Destroy CornPlant2 action destroys all of them since all are picked by default.

    so saying CornPlant2 is overlapping PlacementLocation will pick the instances you want since you already have the correct PlacementLocation picked.

    I would put all crops in a family, and give the family an instance variable called Location, and assign that variable when the crop is spawned. Then you can pick crops by their location.

  • that actually turned out to be slightly harder than I expected... maybe I am just tired :)

    this file merges 3 arrays loaded with AJAX at the start. It also populates a drop-down list so you can check that the levels match the project files... each project file is only 10 sheets of 8x8 cells but it will work with as many sheets as you can give it. The AJAX data is loaded into a TempArray. The LevelsArray starts out with a depth of 0 and then each sheet is pushed on the back of the array as it is loaded.

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