R0J0hound's Forum Posts

  • Can't open your file. I think it's not publicly shared?

    Probably that wait is causing problems, but I can't really follow it.

    Anyways this should measure the total length between multiple instances of sprites making up the chain.

    var totalLength=0;
    
    for "" 0 to p.count-1
    -- loopindex = 0
    -- -- set totalLength to 0
    -- else
    -- -- add distance(p(loopindex-1).x,p(loopindex-1).y,p(loopindex).x,p(loopindex).y) to totalLength
  • Awesome Rojoh!

    Working great here on (Windows + Chrome)

    Thank you))

    Glad it worked. Just updated the css file to replace most of the pink icons on the forum as well. If you want a different color you'd have to edit each one.

  • Tested my idea:

    dropbox.com/s/9uksvlft6yxnx6f/transparent_when_behind.c3p

    Z goes up instead of down so that last condition needs adjusting and it works.

  • In an effort to get rid of the pink I made a css file to change the color in as many areas as I could.

    dropbox.com/s/4x3vuplxii5zzlq/Scirra_less_pink.css

    Tested as working on:

    iOS Safari using Userscripts extension.

    Windows Chrome using "User Javascript and CSS" extension.

    Other browsers likely has extensions where you can inject user css too.

  • A slightly different way you could do it is to sample points on the line between the camera and each tank. If any point overlaps a wall in 2d and the point z is between the top and bottom z of the wall, then that point is inside the wall and you can make it transparent.

    The events would basically look like this:

    var steps=0
    
    every tick
    -- tank: set opacity to 100
    
    for each tank
    -- set steps to ceil(sqrt((camera.x-tank.x)^2+(camera.y-tank.y)^2+(camera.z-tank.z)^2)/32)
    -- repeat steps times
    -- pick wall overlapping point: lerp(camera.x, tank.x, loopindex/steps), lerp(camera.y, tank.y, loopindex/steps)
    -- value lerp(camera.z, tank.z, loopindex/steps) is between wall.z and wall.z+wall.zheight
    -- -- wall: set opacity to 50

    I can never remember if z goes up or down so the code assumes z goes up. If z goes down you’d need to change the in between values condition to: wall.z-wall.zheight and wall.z.

    In the steps calculation it uses 32 to make it sample points every 32 pixels. You can make that smaller to make it more accurate although it would be a bit slower.

  • Hi,

    The new hot pink text color is pretty harsh on my eyes. The previous green color was better. Maybe as a compromise a setting could be added to the user profile to let users use a different color if they so choose?

    Thanks

  • Cool, glad you got it working. I think you could possibly just use the body and the canvas will inherit the same stuff. Anyways I think that touch- callout may have been key.

  • Hmmm, well this can be solved by the user-select css property according to my research. There are two variations of that to work with safari and internet explorer. I can't seem to find where this is used in C2 but I haven't looked too hard in C3. Could this be something that was overlooked? It probably should be reported.

    Anyways running this script at the start of the layout should fix it I think.

    c3canvas.style.webkitUserSelect=c3canvas.style.msUserSelect=c3canvas.style.userSelect="none";

    Edit:

    It's not an issue on pc best I can tell. I was able to test this on safari on ios and this does keep the canvas from being selected.

  • It's mostly just a bunch of perlin noise mashed together.

    Possible example. In C3 just use the advanced random noise instead. Anyways it's just a lot of number fiddling.

    dropbox.com/s/9shcpwjkf4spvwb/noise_gen4.capx

  • If you mean you move the cursor around with the Gamepad just like a mouse then it’s fairly straightforward. You’ll need three events: one when the button is pressed, one when it’s down, and one when it’s released.

    I’m assuming you have a cursor sprite that you move with the Gamepad. Anyways, give it three instance variables dx,dy, and obj2drag. Obj2drag should start as -1. Then the events would look like the following to work with one sprite type.

    on button pressed
    pick sprite overlapping point cursor.x, cursor.y
    sprite: pick topmost
    -- cursor: set obj2drag to sprite.uid
    -- cursor: set dx sprite.x-cursor.x
    -- cursor: set dy to sprite.y-cursor.y
    
    is button down
    pick sprite by uid cursor.obj2drag
    -- sprite: set position to cursor.x+cursor.dx, cursor.y+cursor.dy
    
    on button released
    -- cursor: set obj2drag to -1
  • Construct should block that internally. What kind of mobile device? iPhone or Android? What browser?

    From what I gather from googling there is some css to make something not selectable and/or some JavaScript to stop the default behavior in a touch input handler.

    I ask because I’m interested in the cause and solution myself. I haven’t had a chance to do any tests yet though. Overall I think that sounds like a bug or at least something that should be fixed. Have you tried filing an issue? It sounds easy to reproduce.

  • There are always multiple ways to do something. Here's one way in addition to previous examples and such. My examples are meant to be something to fiddle with and maybe get some ideas how something could be done.

    It just converts a qarp curve to a polyline and lets you move some distance up and down the polyline.

    dropbox.com/s/m0pk8zvqoj08kr7/move_on_dashed_curve.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are lots of ways to do curves, but for that particular one you could use a Bézier curve or an arc.

    Generally for most curves you can get a formula to get any position along it by t. But the speed will vary as you move along it, so the solution to that is to convert the curve to a polyline so you can move along it at a constant speed.

    Anyways here’s the simplest formula to move on a curve. A and C are the end points and B is a control point, and t changes from 0 to 1.

    X=qarp(ax,bx,cx,t)

    Y=qarp(ay,by,cy,t)

    Again if you want to move at a constant speed along the curve you’ll need to use the formula above to get a list of points along the curve then move between them in straight lines. Another way is called arc reparameterization which avoids the polyline but requires more math to get an integral we can evaluate numerically.

    A second idea in that specific curve is to just use the arc on a circle. You can derive the center and radius from three points on the circle and using this formula for the tree points. Then solve using algebra.

    (X-centerX)^2+(y-centerY)^2=radius^2

    Then you can get a point on the circle with

    X=radius*cos(a)+centerX

    Y=radius*sin(a)+centerY

    So to move along an arc you lerp between the angles from the center to the endpoints. That will be constant speed.

    I don’t have time to make an example but I’ve done something similar a lot so a forum search of my posts will give a fair amount of results.

    If that plug-in works for you I’d go for it as well. I have not tried it.

  • I dealt with that a bit when I made a spritefont generator. The text is drawn with the canvas api and that doesn’t provide a way to measure the visual bounding box of text. It gives the width enough to space text well but nothing about stuff that overhangs.

    Anyways, I just oversized it and centered the text to avoid the clipping.

    You could avoid the warping entirely but just adding new lines as needed. That way you could ensure there’s a buffer to the right.

  • That’s trickier. One quick way could be to use the line of sight behavior to see if a wall can be seen by the player and if it is move the wall to a layer above the shadows.

    Otherwise I’d give it more thought and do the shadows another way. Probably drawing them with the canvas plug-in.