R0J0hound's Recent Forum Activity

  • I’m guessing you mean you’re using lerp like this:

    Set x to lerp(self.x, target.x, 0.01)

    That does slow down as it reaches the target. But to ease as it moves away you’ll have to do something different.

    I believe with the move to behavior you can specify the easing function as you move to a point. That would be the simplest solution.

    You can do the same with some math and a few variables. You’ll need the start and end positions and variable to indicate progress. For example this does an ease in and out.

    Var t=0

    Every tick

    — add dt to t

    — set x to cosp(startx, endx, t)

    Another idea is to use a velocity to control the motion. Could be as simple as adding 100*dt to the velocity to accelerate away. Maybe just switch between lerping accelerating away.

    Yet another idea is to do the easing with a damped spring. You’d need the velocity and two variables k and d which control the spring stiffness and damping. Both are in the range of 0 to 1. Fiddle with the values to control motion. Could be useful when the target constantly moves.

    Compare: dt>0

    — ufo: add -k*(self.x-target.x)/dt-d*self.vx to vx

    — set x to self.x+self.vx*dt

  • You are getting the object type, and that doesn’t have a text property. You need to get the instance from the type to be able to access text I imagine. Refer to the docs, tutorials or examples on how to correctly access an instance.

  • After some digging I found this site that gives a 1 inch square, at least on my phone.

    https://www.hyperspaces.co.uk/device/

    The code can’t be used without permission it seems but looking at the code shows how it was done.

    Looks like it works by roughly having a list of all devices and their physical screen sizes, and using the values provided by the browser to figure out what device is being used. However in many cases it mostly has to guess.

    It’s probably as laborious to do as it sounds, and will only be good for the devices it knows about.

    Other than that it’s as Ashley says, it’s not possible to get the physical screen size from the browser with JavaScript. Everything I’ve found either says it’s not possible or is wrong.

    The only other idea is if you’re doing an android or iOS export they may be able to access stuff like that. But it just depends on what is exposed to the sdk.

    A setting for the touch controls scale seems like the easiest solution.

  • You do not have permission to view this post

  • If you made the movers slightly smaller it may help. The reasoning behind that if the collision will only be triggered once per the objects overlapping the walls.

    You could also try adding a “for each mover” to the on collision events. The reasoning for that is if the on collision condition picks all the colliding movers in one shot it could possibly need to be handled one by one but I haven’t looked at your events too closely.

    Third thought is the bullet behaviors bounce action may not be robust enough to be super reliable. But that’s just a thought

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try opening the browser console and see if typing that function, registerProcess, is defined.

    If it is then it likely has to do with the scope that c3 ran the script you typed. It’s probably mentioned in the manual.

  • There is a wrap behavior that kind of does that. But it’s imprecise.

    You also do the wrapping with events and make it a bit better. Here for example the screen is 640 pixels wide. It’s the most basic example and you’ll see when the objects jump from one side to the other.

    Object: x<0
    — object set x to self.x+640
    Object: x>640
    — object set x to self.x-640

    You can solve that by making the position jump further off screen by some margin. A good rule of thumb would be a margin at least as wide as the widest object you’re wrapping around.

    Object: x<-margin
    — object set x to self.x+640+margin*2
    Object: x>640+margin
    — object set x to self.x-640-margin*2

    Now that’s is the scroll position is to the left of the layout. You could make it relative to the screen if you really need to.

    For doing it with a tiled background you’d just need to have the tiled background’s width to the imageWidth+screenWidth and the events would basically be:

    tiledbg: x<imagewidth
    — tiledbg set x to self.x+imagewidth
    tiledbg: x>0
    — tiledbg set x to self.x-imagewidth

    Now if you change the x by more than the imagewidth it will take more frames for it to catch up. Adding a while condition above the x compare conditions is a simple fix. There is probably a nice math way to correct it without a loop too

  • Well I still don’t fully understand how you want it to work. I’m guessing you have a box per spawner, and you can select a box. Then clicking a button will create/ recreate the boxes that aren’t selected.

    Global number pickedBox=-1
    
    On box clicked
    — set pickedBox to box.uid
    
    On spawn_button clicked
    [negated] box: pick by uid pickedBox
    — box: destroy
    
    On spawn_button clicked
    [negated] spawner: overlaps box
    — spawned: spawn box

    If you set it up in the layout so each spawned has an overlapping box to begin with then the last two events could be merged into

    on spawn_button clicked
    [negated] box: pick by uid pickedBox
    Spawner:overlaps box
    — box: destroy
    — spawner: spawn box

    But then I wonder if we need to even recreate the boxes at all.

    Again that’s why I don’t think I fully understand fully what exactly you wanted it to do.

  • Probably load the image to an animation frame of a sprite, paste the sprite to drawing canvases the size of the frames, and finally use the drawing canvas save image feature. After that you could load those images as frames.

    An alternate idea is to just load the image into the sprite with a 2x2 mesh distort and just change the UVs of the corners to select a sub image.

    You could also use a tiledBackground by setting its size and the image offset to select a sub image. But loading images at runtime with that is per instance instead of shared between instances. Which may or may not be an issue

  • I feel it could be made simpler but I don’t understand what the desired behavior is from reading your posts.

    When the spawn_button is clicked you want to destroy any boxes that aren’t selected and create boxes on any spawners not overlapping a box? Sounds simple enough but looking at your events it looks like you have more complex behavior in mind?

  • One way is to just pick a random tile and check to see if it’s not red and is next to a red tile.

    For example with a 100x200 tilemap you’d get a random tile with:

    set x to int(random(100))

    set y to int(random(200))

    Then the rest is just comparing the tile at a location. It would need to run multiple times to select a tile to fill.

    Now a more direct way could be to loop over all the tiles and store a list of all the valid locations to an array and randomly choosing one of those.

    If you’re clever you could make it so you’d have to loop over everything only once and add and remove from the array as you go. You could try looping up flood fill algorithms to get some ideas too.

  • You said the set position action, did you mean the look at action?

    The reason you can’t set the up vector directly is it’s related to the forward and right vectors. They all have to be perpendicular from each other.

    What the look at action does is set the forward vector directly, the calculates the right vector from the forward and up vectors, and finally it calculates a new up vector from forward and right so everything is perpendicular.

    The lookat expressions I haven’t used. They seem to relate to the rotate action.

    If it jitters then I’d say post your events. All I use from the 3d camera object is the look at action which updates the up,forward and right expressions immediately.

    So I guess my untested question is do the look at expressions get updated immediately too or is it delayed till things render? Genuinely curious. I know the text.textwidth expression only updates after the text is drawn so maybe something else is happening here.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound