R0J0hound's Recent Forum Activity

  • There's always the feature request page if something is lacking.

    From what I’ve briefly found looking at html5, I’d probably do it the same as with my solution. Is there a built in way to restrict to only numbers? Maybe, but it’s simpler to just do myself. It gives the ability to restrict the input to anything I’d desire.

    Personally the “why” doesn’t interest me a lot. It could be an intentional design choice, or maybe oversight.

  • I think what you’re missing is sub-events. You can drag an event under and to the right of another event to make it a sub-event. Kind of like indention formatting of some programming languages.

    Hope that helps.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry, I haven’t a clue. The plugins I mentioned were c2 only, although I think blackhornet ported paster to c3 somewhere.

    I thought you were asking about in c2.

  • One idea that comes to mind is to let the text box be normal and under a “text changed” condition you can check what was typed and limit it to numbers or numbers with decimals. Actually you could use float() with this too.

    textbox: on text changed
    compare: len(textbox.text)>0
    — textbox: set text to float(self.text)
  • Distorting sprites like that isn’t really possible with vanilla construct.

    One possible way could be a shader. There are many effects that people have made to distort an image. Most are pretty specific and they don’t really fit the requirement to be able to distort an image arbitrarily.

    Another idea would be to do it like texturing is done in a 3D modeling program. You’d set the position and uv coordinants of of vertecies. But again you can’t do that in vanilla construct.

    There are two plugins that can be used to do it though, with varying ease.

    The first is Paster. It has a draw quad action that can do the distortion. For curved you’d do lots of smaller quads.

    Another plugin is “custom draw.” Very similar but is simpler in a way. It’s topic has a few distortion examples.

    A third way is with some custom webgl in JavaScript to draw the distorted mesh.

  • This was reported as a C2 bug and not a C3 one. Also I think tagging the devs in posts in the bugs section is kind of redundant.

    Anyways, what's happening is the textbox object, once selected, blocks most all input events from passing through it to anything else. So the keyboard state (which is stored in a array in the keyboard object) isn't updated when the spacebar key is released.

    I'm not the developer, but you can make the keyup events not be blocked from the textbox object as a self fix. It would make the key released triggers fire as you type stuff, but perhaps that's acceptable in your case.

    Anyways, set the textbox id property to something like "foo" and then using the browser object run this code:

    start of layout
    -- browser: execute js: "$(document.getElementById('foo')).off('keyup');"

    I don't think it would work in C3 unless jquery is used in the textbox object.

    Alternatively, I guess if you wanted more control you could just do your own textbox with events and filter keyboard events yourself. Last I checked the keyboard object wasn't quite up to snuff to get typed keys with case and such, so you could capture keys with a little js as well. I thought I had posted this before, but I guess not.

    ucf4f5901e4b2339617d497dd05f.dl.dropboxusercontent.com/cd/0/get/Ch5PitZZhvlm6Nv3myvjP_rSGzA6WKFpKfkqV-AJvBn0ZIwjbmSHr7x8q3tXqMikxxAwUJspu3lOc1ScCQuGst9u_B8ZjlZxKcyxRm12WjP4PVxRj34ADzAeUtug9hLZxco/file

    cheers

  • Array.asJSON, when parsed as javascript gives a dictionary with an entry with a 3d array. Do you really need to convert it?

    You could build your own array with text from the array before passing it.

    global text arrayText = ""
    every tick
    -- set arrayText to "["
    array: for each x
    -- add array.curvalue&"," to arrayText
    every tick
    -- add "]" to arrayText

    Then just pass arrayText when you call some js.

    You could also build a 1d array from it after passing it, or even just use it directly. I mean say you did:

    browser: execute js "myfunction("&array.asJSON&")"

    then in that function you'd access stuff like this:

    function myfunction(c2array)
    {
    	// access value at x=22
    	c2array.data[22][0][0];
    	// access value at x=3, y=2
    	c2array.data[3][2][0];
    	// access value at x=13, y=66, z=5
    	c2array.data[13][66][5];
    }

    Notice it's always a 3d array.

    If you want to convert the 3d array to a 3d one then just go for it. It's the standard type of thing to do when writing code.

  • Even a hidden html5 canvas will use video memory. Internally the browser is using the graphics card for basically any and all rendering.

  • Oh interesting, I didn't know "multiply" was one of the options now. It didn't used to be. I'm not sure if that would cause compatibility issues on some browsers.

    I hadn't thought of creating individual letters of different colors as needed and keeping them for later use. Probably works well when only using a limited amount of colors. If the user ended up trying to do gradual color transitions you may run out of video memory though.

    It's not bad to end a batch in c2's renderer. It does it all the time. All a batch does is it sends multiple quads using the same texture at the same time instead of separately. Besides you'd be doing your own batching of all the letters in your spritefont renderer. The only drawback is if multiple spritefont instances drawn right after each other then they could only be batched individually instead of together, but I say it doesn't matter too much.

    It seemed fun enough to try my hand at webgl again and try using my own shaders instead of working within the limits of c2's shaders and renderer. I must say webgl tutorials seem to add a lot of cruft to their code. It actually seemed fairly straightforward.

    Here I used the browser object to replace the drawGL of one instance to test stuff out. It uses it's own shader program and supplies it's own vertex,uv and color data. The only things I had to save and restore in the c2 renderer was the current shader program and arraybuffer it was using. Otherwise I tried to reuse as little as needed from the renderer, which amounted to just the view matrix.

    uc431d0c7caed3a8a31113f0c8f0.dl.dropboxusercontent.com/cd/0/get/Ch8t3GzRTJvrgR9GVsXVbb-jlFi1qJQrrELJHnSxajQET5VxKFvYZP3wZbEioYM-Eul9bxIWaVGmSfdM3DHf4S9jEhnTd4m-LW_DtABhiFWQo_dYnBYljHZWj3h5rS_e_nw/file

    Maybe that could be a useful example to use alongside a webgl tutorial.

  • We are still talking about spritefonts though, which is a quad per letter. Here the question was ways to do a different color per letter. I seem to recall c3 solved this with their updated spritefont object. This is mainly because c3's renderer adds a per quad color multiplier.

    You're probably thinking of geometry based. It's relatively simple to draw a bunch of quads. Although it's probably tedious to design or convert existing fonts over. You'd still want to use some custom webgl to do multiple quads faster and color them.

    Anyways here is a nice list of all the methods of doing text in webgl:

    stackoverflow.com/questions/25956272/better-quality-text-in-webgl

  • As I recall the Klik n Play example you got the graphics from used an actual user defined path to move around the track.

    The pathfinding behavior in construct is probably not well suited for this. Typically you'd define waypoints you'd want to pass through before telling to to find the path. You'd only do this again when the end of the path was reached.

    An example capx is always better than images, but it probably stops because the pathfinding behavior will slow to a stop when it hits the grid containing the destination location, so it may not collide with those sprites to pathfind again. Setting the cell size smaller could be an idea, but wouldn't be great for performance.

  • I'd say for simplicity don't mess with the internals of C2's renderer. It's designed to draw quad and point batches as well as using effects in a way that's best left handled by the editor.

    So If you want to draw in webgl you should be able to call glw.endBatches() or whatever it's called and then use any webgl you want. Just save all states you change and restore them when you're done. The creature2d plugin does this and performance seems to be decent.

    My guess is you'd replace the shader used by default with one that takes a color per quad as a parameter too, so it would multiply the texture with the per quad color to get multiple colors. I'd say first try it out in straight webgl outside of construct to get the concept down. Then you can do it in construct and see how much of the c2 renderer's webgl state you can reuse.

    For rendering it with a html5 canvas you could probably do it by using two canvas'. One you'd draw the text in white to, and the other you'd draw colored rectangles for each letter. Then as a final step you'd use a blend mode to combine the two to make colored text.

    If you're concerned about performance don't use a html5 canvas method when you plan on drawing with webgl. The main issue is the canvas will need to be copied to a webgl texture every frame it changes. This is why C2's text object is slower, as well as my own canvas plugin.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 156 followers

Connect with R0J0hound