Skip to main content

Posts

Showing posts from October, 2016

15_10_2016 Drawing + Coloring

The Cyclops

Godot (GDScript) Memory Management

I've been working with the cocos2d-x engine for a while and have gotten used to one of the important features in the engine.. the autorelease(). It's basically a reference counting implementation which automatically deletes any object that is removed from a scene. Unless ofcourse you called a retain on it. So when i was working on DotDot a simple 2D game, i created a crosshair animation everytime the user got a perfect alignment and removed the object once the animation was done. It worked great and for a while i assumed that everything was fine. I was showing off the game to people on my android device when i started noticing slowdowns once in a while.. and as the score got higher it got worse.. surely the engines' fault i assumed.. but then i thought ill' give Godot the benefit of doubt and checked the documentation about freeing the memory. That is when i discovered that the objects removed from the scene are not actually removed from memory. Basically every tim...

Pixel perfect mouse click on Images in Android Canvas

I was trying to build a sample for some image manipulation tool. The requirement was that the user should be able to pick an image that he pasted on the screen, move it around, scale and rotate it. The way we would do this using OpenGL is create a depth buffer use different depth value on each of the Quads' used to render the transparent image. So when you do a readPixel from the depth buffer you will get the z value of the sprite if it was under the touch. This is how we wold distinguish between two overlapping transparent images. The tracking of z value for different Quads is done automatically in OpenGL when you bind the depth buffer to the current frame buffer and start drawing stuff. Now this i know and have used for a while, but how does this work in the Android Canvas drawing world? Short answer: in the same way Long answer:  These are the steps you should follow to get it done: You have to create a separate Bitmap of the same size as your drawing area Set the ...