Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi ! I'm trying to make coppercube responsive html. If the canvas measures more than 700px it shows an object, if the canvas measures less than 700px it shows it. This is my code and it runs //Before first drawing do something
Does anyone see any errors? Thank you ! |
||||
|
Why, isn't it working? If so, what says the browser javascript console? It was reported the "do something before first drawing" would do it every frame - under bug reports. I see some lines should have a semicolon at the end, but browsers seem tolerant these days. Thanks for sharing. It is great to have access to the html, css and js functionality from within CC. |
||||
|
Thanks for the reply. Yes, for some reason it doesn't work. |
||||
|
addListener and matchMedia I don't know - this is far from how I code, sorry but I can't help you with these. But one thing people misunderstand is: "do something before start drawing" isn't meant to be executed only once at game start, but (correct me if I'm wrong) every frame BEFORE the frame is rendered. It gives us a way to insert JS at this position in the pipeline, that may have diffrent implications compared to a behavior. That may be useful in respect to collision handler, but also to access the canvas pixels. For example the WebGL command to copy the canvas to an array gave me a black screen in the array, when executed in the behaviour with onAnimate every frame. Only after I used this:
|
||||
|
Probably too late, but as I just stumbled upon this thread, today I would implement it this way, or try to: First of all, I use the copperlicht.js directly, I only use Coppercube to assemble me a package of mesh and sound assets into a ccbz file, that I then can access in my main script. There is an option to do certain things once right after loading is complete:
|
||||
|
quote: engine.ingComplete wtf This forum messes up code contributions! Screw this Niko. It was engine.O-n-L-o-a-d-i-n-g-C-o-m-p-l-e-t-e, but in fear of haxxors all js event handlers are erased - how unelegant. You only have to filter all < (greather than) and > (lower than) and make them > and < to prevent any code injection. That includes all input fields, not just the textarea, and script crossorigin must be denied. |
||||
|
oops, I meant You only have to filter all < (greather than) and > (lower than) and make them &-g-t-; and &-l-t-; to prevent any code injection. (minus the minus signs in &-l-t-; of course) |
|