R0J0hound's Recent Forum Activity

  • Maybe something like

    Every tick

    —sprite: set frame to self.framecount-1-(time*self.animationSpeed)%self.framecount

    The speed has to be a positive value but that would play the animation in reverse order.

  • Probably the closest C3 feature is "custom actions" which are like functions that are attached to an object type. It's just as easy to add as an actual function. Right click on the event sheet and select "add function" or "add custom action".

    Besides that, you could probably implement the logic in some different ways that work better with C3 events. For example, You could skip functions entirely, or only use them to not have duplicate stuff.

  • If the squares are sprites it’s just a matter of looping over them in order. You can use “for each ordered” to do that or if you placed the instances in a specific order then a normal “for each” could work.

    One way to do the events could look like this:

    Var out=“”
    Var x=0
    Var y=0
    
    On button clicked
    — set out to “”
    
    On button clicked
    For each sprite ordered by 1000*sprite.y+sprite.y ascending
    — set x to loopindex%8
    — set y to int(loopindex/8)
    — add (x=0)?”BITMAP “””:”” to out
    — add sprite.animationFrame=0?”.”:”#” to out
    — add (x=7)?””””&newline:”” to out

    Or basically loop over the squares a row at a time and output a . Or a # depending on the frame. Then, as citron mentioned, just add the Bitmap, quotes and newline when at the start or end of a row.

  • The actions that call the function are the ones to look at if you want to know how it specifies the uid to use.

    Since c2 functions don’t know what was picked when you called them you often need a way to specify what instance to pick. Passing an object’s uid as a parameter is one way to do that.

    As a minimal example it could look like this:

    On function: “rotate90”
    Sprite: pick by uid function.param(0)
    — Sprite: rotate 90 degrees
    
    Start of layout
    For each sprite
    — call function “rotate90” (sprite.uid)
  • That’s a pretty cool idea. Erase a hole and draw in the hole. I’ll be adding that to my toolset.

    Edit:

    Main limitation of that method is the mask needs to be completely contained within the object's pixels. And it doesn't work on transparent layers with force own texture. Still pretty cool.

  • You’re probably referring to the scissor cut feature that webgl has that was one of the things that c3’s renderer batched. It was never an sdk feature, but a way to use it was found before sdk2 (which walled a lot of stuff away). Anyways, all it did was limit rendering to a bounding box on the screen. I don’t think that really helps solve the masking issue unless all you want to do is mask by a rectangle.

    The issue you have is the mask isn’t covering all the objects underneath. Using layers you can effectively first draw the mask to a full screen texture and use the blend mode on that.

    You can do the masking by having a layer with two sub layers. You’d put all the objects you want to mask in the first sub-layer, and the mask object in the second sub-layer. Just have normal blend modes on all the objects, but use the “destination in” blend on the second sub-layer itself.

    You could likely do it by drawing objects to a drawing canvas as well. But you’d still need two of them since you need to make the mask cover everything you want to mask.

    I don’t think it’s really something that’s feasible to do from the sdk from what I can tell.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The browser doesn't provide much control with how it rasterizes text. Unless Construct wanted to do their own rasterizer with the freetype library or something like that.

    Here's an updated example that draws text and outlines using an sdf based sprite font. It's a tad simpler than the previous one, but lets you specify font size and colors. Only issue is there are some limits with how big of an outline you can have depending on the generated sdf image.

    dropbox.com/scl/fi/tt071d610pfzqfyda8czj/tiledbg_based_sdf_text_with_outline.c3p

  • If you only have a limited amount of text like that you could just pre-draw the text to images. I'm sure there are programs with font rasterizers that don't glitch like the one in some browsers.

    If your text can be a lot of different things you could instead try using a spritefont to do it. To do the outline you'd have two spritefonts, one for the outline, and one for the normal text. You'd just draw the outline first and place the text over it.

    Here's a test of that idea. I didn't use a generator that is easily adaptable to the spritefont object, but it's simple enough to use a tilebg to draw it char by char. There is some tighter kernelling in the json, but I didn't bother with that. The outline width is baked at 10px.

    dropbox.com/scl/fi/lzm4uaui3n7vs34tqt08v/tiledbg_based_text_with_outline.c3p

    As an exercise you can make the text scalable. You just need to multiply most values by a scale number. However, that would change the outline width as well.

    You could also extend the idea by using an sdf spritefont. There is a threshold effect that could be used to convert the sdf to crisp letters. Also, you could use the same sdf to draw outlines with dynamic widths. You'd have to test to see if that effect is up for the job.

  • This looks familiar somehow...

    What we do know is an outline effect works by coloring transparent pixels if there are pixels around it that aren't transparent on the texture.

    Maybe since the effect samples pixels far from the pixels on the sprite it could be sampling pixels from other sprite sheeted images.

    So maybe the effect isn't clamping the sampling to to just within the current sub-texture.

    If that is the case then either the effect could be modified, or we could take advantage to how the c3's effect compositor works to avoid sampling beyond the frame (sub-texture). You could do that by adding another effect to the object, and order that to be before the outline effect. When there are multiple effects the first effect is drawn to a temporary texture and that is used as input for the next one. With that nothing would be beyond the image to possibly sample.

    Anyways, just an idea.

  • If you're just doing it in events without behaviors, you will also need to handle the collisions with events too. That involves checking for an overlap with obstacles and then moving out of the obstacle and maybe updating the velocity.

    There are many ways to do that, but one way to do an event based movement for a jump with gravity would be:

    on any key pressed
    -- sprite: set vy to -100
    
    every tick:
    -- sprite: add 100*dt to vy
    -- sprite: set y to self.y+vy*dt
    
    sprite: y > 400
    -- sprite: set y to 400
    -- sprite: set vy to 0

    That last event acts as the collision detection and response for a ground at y=400. Likely you'd want to collide with actual objects but that would get more involved.

    One possible solution could be to move backwards till no longer overlapping. or in the case of landing on some ground you'd move it up.

    on any key pressed
    -- sprite: set vy to -100
    
    every tick:
    -- sprite: add 100*dt to vy
    -- sprite: set y to self.y+vy*dt
    
    sprite: vy>0
    while
    sprite: overlaps ground
    -- sprite: set y to self.y-1
    -- sprite: set vy to 0

    You'd likely want something similar when moving up, left, and right, just need to go backwards by pixel steps (or smaller steps to have smaller gaps). A common technique is to handle horizontal movement first, then vertical movement.

    Instead of moving backwards in steps it is possible to calculate exactly how far to move the object to not be overlapping, but that's less trivial to do.

    You could also utilize a behavior that has control turned off as a quick way to handle the collision response for you, but you get less control, and usually they work better when it's that behavior that moves the object.

  • You only need to access node transforms. Objects and bones are just nodes in glb files.

  • Nice feature request. But in the meantime you could build the model with those objects and toggle their visibility.

    Another idea could be to load the glb/gltf file directly and parse out the skeleton and animation data, then transform that to match the 3dmodel. It works but in my tests making a glb loader I haven’t been able to get the Skelton to perfectly match the 3dmodel yet.