[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Mon Jul 27, 2015 3:31 am

@Edelplastic
I think I didn't explain it well. Here is what all the parameters of the "draw line" action should be. I just used the standard names of objects to make it more clear.

sprite.x-canvas.x
sprite.y-canvas.y
mouse.x-canvas.x
mouse.y-canvas.y
"rgb(0,0,0)"
2
B
79
S
24
G
54
Posts: 4,754
Reputation: 40,771

Post » Wed Aug 05, 2015 2:07 am

I created a casual game based on the Canvas plugin, designed for mobile devices and unfortunately the Flood-fill doesn't work well on these devices.

I used Flood-fill to detect the internal filling of a circular area designed by the touch of the player on the screen, but when testing him in a smartphone (quadcore with 1GB RAM), the game ran at one frame per second. :(

Does anyone have a suggestion to solve this?

Thank you in advance the attention and collaboration of all. ^^
B
29
S
5
G
1
Posts: 213
Reputation: 2,573

Post » Thu Aug 06, 2015 7:45 pm

@lukezero
Flood filling is a slow operation, even on desktops, so that could explain why it's very slow on mobile. You could try making the canvas lower resolution with the "resize canvas" action to ease off some of the load, but if your game is running at 1 fps then that would probably not be good enough. You could also perhaps do the flood fill only every x seconds to space out the slowdowns.
B
79
S
24
G
54
Posts: 4,754
Reputation: 40,771

Post » Thu Aug 06, 2015 8:57 pm

Well @R0J0hound, the game starts in slow motion, even before I draw the line. I'm using a canvas rectangle with the size of the screen to recognize the player's dash.

It's also causing the slowness?

PS.: The floodfill is only and quickly executed when I close the circle amending the circle starting point at the tail end. After the floodfill, I execute immediately a Clear Canvas command.
B
29
S
5
G
1
Posts: 213
Reputation: 2,573

Post » Fri Aug 07, 2015 6:34 pm

@lukezero
It may perform better with webgl off. With webgl "on" a texture copy needs to be done every time the canvas is changed, which is slow.
B
79
S
24
G
54
Posts: 4,754
Reputation: 40,771

Post » Fri Aug 07, 2015 8:53 pm

Thanks for your attention and support, @R0J0hound. :D
B
29
S
5
G
1
Posts: 213
Reputation: 2,573

Post » Thu Aug 13, 2015 11:23 am

Message: wasker is not yet permitted to post plain text URLS (300 rep required). 2 URLS removed. Why?
Hey hey,
I'm very *very* new to Construct and writing instructions but I tried to follow your example @Rojohound for making a mirrored waterlike surface ( in this thread.
I can for the life of me not figure out how to extend the surface to the entire bottom of the screen. I've tried changing all the numbers, changing the canvas height value to 50+ and adding and instruction to cover the entire lower part of the screen but but then all i get is a stretchy texture and no ripples :)
B
3
Posts: 2
Reputation: 179

Post » Thu Aug 13, 2015 7:11 pm

I can't see the link you posted but to do a mirrored water like surface it's just a matter of positioning the canvas with it's hotspot on the bottom of it. You'd then position it in the layout so the bottom will be where you want the top of the water to be. Then in events you'd:
1. paste everything you want to reflect to the canvas
2. set the canvas' height to negative

The effect would basically look like this:
Code: Select all
+---+
|   |
|   |
+-o-+  ->  +-o-+
           |   |
           |   |
           +---+
B
79
S
24
G
54
Posts: 4,754
Reputation: 40,771

Post » Wed Aug 19, 2015 11:23 am

@R0J0hound Can this be used to create alpha based collissions detection using rgbaAt(Mouse.X,Mouse.Y)? For instance make an object uncklickable where it's alpha value is "transparent"? does it take the value of all layers combined? Preferably i would like to get the alpha value of a certain sprite, at a certain point returned to compare it.

I was also thinking of using rgbaAt for detecting other colissions. Let's say you have a 2 sprites with a a circular shaped alpha. While overlapping, detecting if there's any point on this overlap where both of the alpha values from the two sprites adds up to more than 1 would count as a "colission". That could make interesting race tracks using alpha channel as boundries instead of placing a lot of dummy sprites.

Getting the rgba at a point in a certain layer?
If you can get the rgba of a certain point in a certain layer you could use this value to create depth or scale, rotate, move stuff depending on the returned rpga value from that layer. For instance you could have a layer controlling the elevetion of a character in an isometric view by getting the rgba value. Displacing the character upwards depending on the value.

Attaching a mockup to explain what I'm trying to do using rgba.

Image

You could use the ammount of red in an image to control rotation of a sprite. green to control, another value, and blue & alpha to control other things. Don't know weather it's possible or not. but would be really cool to have a "hidden layer" using color info to control certain things.

Color info from Depth maps could also be used to create really cool effects. Scaling an object based on distance when getting the rgba value of the depth map could be very useful to get the illusion of depth. placing a sprite on black will scale it down to match it to the perspecive. placing it on white will scale it up to have it seem like in the foreground.

Image

There's a lot of interesting stuff that can be done with the rgba value i guess.
Follow my progress on Twitter
or in this thread Archer Devlog
B
23
S
8
G
11
Posts: 582
Reputation: 7,413

Post » Wed Aug 19, 2015 5:55 pm

@tunepunk
There is also redat, blueat, greenat and alphaat expressions to get individual components of color. That said, it only reads the color from the canvas object itself so you need to paste stuff first to read it's pixels.
B
79
S
24
G
54
Posts: 4,754
Reputation: 40,771

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests