How to pour liquid in game maker? - game-maker

I want to put water sprite inside the flask and when i drag it on top of the container it pour this water into the container.
Does anybody know how to do this in game maker?
And here is a picture of the flask and container

You could use a rectangle that is only visible through the sprites of the recipients and change it's scale when you pour it. For example, link it's image_yscale variable to the quantity of poured liquid.
If you are motivated, shaders could be the solution. Otherwise, you could simply design flat-bottomed recipients, make them transparent, and use the draw event to draw a liquid-colored rectangle inside of them before drawing them. The result won't be as astonishing, but far easier.
your draw event could look like ;
1 - draw the rectangle at the x & y coordinates (you may have to use an offset), with the correct scale using image_xscale & image_yscale, and the correct angle which is the flask's image_angle variable.
2 - draw the recipient after that.

Related

Add marker/dot on image at accurate pixel with zoom in/out functionality

I'am using reactJS and want to design a component with following functionality :
Display pixelated image which is able to zoom in and zoom out at pixel level.
When clicked on image , display a marker- which can be a dot or icon at specific position.
When image is zoomIn/zoomOut, marker size and position should not change.
Even after zoomIn/zoomOut when clicked on image, marker should get repositioned at proper pixel on the image.
I am thinking of applying same logic as used in the maps/ leaflet. Like they maintain separate layers for map and markers on the map. If we zoomIn/out maps it won't affect the marker position or size, same functionality I want for the image.
Anyone with the solution or related library will be welcomed !
(For reference, I want this design for marking GCP(Ground Control Points) on the image, which requires very precise marking at pixel level)

Scaling down Raphael World Map

I'm currently creating a splash page for a project website. I was instructed to design a world map with a menu on its side and add some blinking effect while hovering on the sub menus.
I'm done with transforming/scaling the map, but I'm having a problem when hovering on sub menus, the small red circles doesn't pop up on where it should be.
Without the .transform() method, the small red circles pop up correctly, but it gives me a big but cropped map.
I used .transform() method to scale the world map down.
I put .transform() method here:
r.path(worldmap.shapes[country]).attr({stroke: "#9b59b6", fill: c, "stroke-opacity": 0.25}).transform("s.628,.740 0,0");
Here's the page with transform() method.
Here's the page without the transform() method.
In the code all of the locations of the cities is stored as lon/lat coordinates in the name attribute. This is then parsed through a world.parseLatLon function which then calls getXY() . I would say that in the function getXY the returning coordinates need to be transformed as well. There is some interesting number manipulation that is going on there (multiplying by 2.6938 and then adding 465.4) - I would say that this is adjusting the coordinates for the size of the image. Now that you have changed the size of the image, these will also need to be adjusted

Finding color on flex page

I want to find some color on flex page exists or not?
For example
if(red color exists on page){
Alert.show("red exixts");
}else{
Alert.show("red does not exists");
}
so before writing this if else block,i need to find the red color(any where on flex page)
Note:- My page do not hav any images.with images i m getting the color.My page has a canvas and hboxes and diff texts with diff colors.
Done with bitmap,bitmap data.....NO LUCK :( Please help me wit this
Draw your page (application?) into bitmap. Then analyze each pixel (may take time). What red do you need? If you accept not only pure red (0xFF0000), define minimum level for red channel and maximum for other channels. As soon as "red" pixel is found, quit checking.
I would suggest that you start iterating over all the children objects of the application, get the colour property, using getStyle("propertyname"), and you will find the colour of all possible objects.This is much better than rendering the whole app, into a bitmap and then testing for each pixel.

Cocos2d grid design for drawing lines

Hello guys
I have a small problem while designing a iphone game with a grid using cocos2d.
The game needs a 10x10 grid in the middle of the screen (it is not covering the entire screen).
A line is drawn at runtime where the user touches two points in the grid.
Question: would tilemap be ideal for this problem? As i need to verify the co-ordinates do belong to the grid or not when the user touches a point would tilemap be useful?
Question: Is there any better way of solving this in cocos2d. Please help me out.
Thanks
I wouldn't recommend using tilemap for this. Personally I'd do it all with math.
Lets for arguments sake say your grid squares are 10px by 10px.
You now instantly know the positions of the rects for each square.
top right square would be (90, 0, 10, 10), this obviously doesn't include the positioning of your grid, but you can easily add that onto this by adding.. (90+gridPos.x, 0+gridPos.y, 10, 10).
Then you just check your touches intersect the rects of the grids.
Drawing a line is fairly simple, i imagine you'd draw it from the center of the 2 grid points.
So if the line started in the top right grid square it's initial point would start at (90+gridPos.x, 0+gridPos.y, 5, 5), or (90+gridPos.x, 0+gridPos.y, gridSquareHeight/2, gridSquareWidth/2)
Using cocos2d it's pretty easy to also make every square a touchable sprite, that can react when touched however you like, sending a message back to a delegate or even just doing a visual effect.
There are tonnes of possibilities for solving this problem.

how to set GDI HDC's drawable region?

I want to draw a HBITMAP onto HDC,
I used StretchDIBits. It works fine.
::StretchDIBits.
however, I only want a window to watch the drawing result, beside the window, I wish the stretchDIBits do not take any effect(It can not draw on other area), how can I do this?
When a child window is created, make sure the WS_CLIPSIBLINGS style is set to disallow painting outside the client area in WM_PAINT.
Other than that, SelectClipRegion is probably what you want.

Resources