Slider in cocos2d [closed] - cocos2d-iphone

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
how to add a slider on cocos2d layer i.e directly on gamescene.m??

you cant add a UISlider directly as a cocos2d node to a layer/scene.
You have to add it as a subview to your cocos2d layer. here is an example:
UISlider *sliderCtl = [[UISlider alloc]
initWithFrame:CGRectMake(170, 0, 125, 50)];
[sliderCtl addTarget:self action:#selector(sliderAction:)
forControlEvents:UIControlEventValueChanged];
sliderCtl.backgroundColor = [UIColor clearColor];
sliderCtl.value = 0;
[[[[CCDirector sharedDirector] openGLView] window]
addSubview:sliderCtl];

For the later version of cocos2d, don't need window in following statement. That support autorotation.
[[[CCDirector sharedDirector] openGLView] addSubview:sliderCtl];

Related

How to develop a Maya Viewport Extension in C++(MFC) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I need to develop a Maya Viewport Extension in C++ with(MFC),also need to control view style(such as top view, left view etc.).Can I use Maya SDK to archive this and how to make it?Thanks.
I'm not perfectly sure what you mean by "Viewport Extension".
I guess you're trying to write a Maya Plug-In that features your own type of viewport, which is commonly called "Model View".
MCF does not have anything to do with this.
You use Maya MEL/Python commands to create Maya windows, panels and other UI-elements.
(if there is a hack to make Maya work with windows you've created yourself, I don't know it).
You can develop custom viewports in Maya by creating two classes:
A viewport or model view, and a "model editor command".
Model View
One is your viewport class, let's call it "MyViewport".
It has to inherit "MPx3dModelView".
Normally you will associate a camera with the viewport. This let's you control from where you see the scene. You can have multiple cameras connected to your viewport (multi-pass display, for example stereo 3D), or none at all (but then you must set all rendering parameters by yourself, which can be tedious).
The (callback) functions you inherit from that class allow you to set up the details for your viewport.
See the Maya documentation on MPx3dModelView to see how to use it.
http://download.autodesk.com/us/maya/2010help/API/class_m_px3d_model_view.html
Model Editor Command
The other class you'll need is a viewport command.
That is the thing that get's called when someone tries to create your viewport.
It has to inherit "MPxModelEditorCommand".
It's most important feature is that it can create an instance of your Model Editor class.
See the Maya documentation on MPxModelEditorCommand on how to use it:
http://download.autodesk.com/us/maya/2011help/API/class_m_px_model_editor_command.html
Registering the viewport command with the Maya plug-in
In order to be able to create your viewport, you must register your Model Editor Command with the plugin.
In your initializePlugin function (the one you export with the plugin)
MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, PLUGIN_COMPANY, "1.0", "Any");
plugin.registerModelEditorCommand(MyModelViewCmd::commandName, MyModelViewCmd::creator, MyModelViewCmd::createModelView);
}
Writing a script that creates your viewport
Finally, you use MEL or Python scripting in Maya to create your user interface.
In the most simple set-up, you simply create a window and then call your model editor command to create you custom viewport in this window.
window MyWindow;
paneLayout MyWindowPane;
MyModelView MyModelView1;

How do I clear a device context? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm not sure if this is something that is possible. But basically the gist of what I need is that a bunch of stuff in my Win32 program is drawn to hWnd through a device context during WM_PAINT. Then through a separate function, I have more stuff drawn to hWnd through the SAME DC. Unfortunately since I use the same DC, the stuff drawn during WM_PAINT is still held in the DC, and is therefore subsequently copied again through my function.
What I need to do is clear the contents of my device context at the end of WM_PAINT or the beginning of my function so that the stuff isn't copied twice.
Why cant you do the entire drawing in WM_PAINT handler ?in the second drawing how do you draw?may be using GetDC to get the device context and draw, right?
The problem is that when you draw outside the WM_PAINT handler, it get erased when the window need to repaint, and the WM_PAINT drawing trump your GetDC based painting, unless you use a bitmat to keep the current context's content
Do all of your drawing to an off-screen bitmap whenever you need to while outside of WM_PAINT, then simple copy the current bitmap to the HWND inside of WM_PAINT.

How to draw directly on the screen in windows? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Say for example that I wanted to draw a red square (or multiple red squares) in the middle of the screen and still be able to see everything not covered by the square, a little bit like a splash screen.
I want to implement this in windows but I don't know the best way to draw on top of the screen. These are my ideas so far:
I initially attempted to draw directly onto the desktop by obtaining a Device Context for it.
Make the rectangle/s a separate window as they would be very easy to move around and I wouldn't have to worry about transparency.
Create a transparent window that covers the entire screen and stays on top. Draw the rectangle/s on the client area of the screen
I think that the best of the 3 ideas is the last one, but any opinions on my ideas, or new ideas would be much appreciated :)
Creating transparent window, then drawing in it, in my experience it is messy.
Why don't you just take a screenshot from the back ground set it as the back ground for you snake game. When ever they click somewhere/die you just close your game.
You could catch the last click and resubmit it after closing the game.
That is how I would do, but of course that just an opinion.

How do i make background blur when i open my app? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have to make the background (of desktop) blur when i open my app.how do i do this please help me out with hints or links..
Take a screenshot.
Apply some blurring to the screenshot bitmap (e.g. Gaussian).
Display a fullscreen window with processed screenshot as content.
Show your window on top of the fullscreen window.
The details depend on the OS and the technology you are working with.
If dimming instead of blurring is OK, you can just show a black fullscreen rectangle with alpha less than one (as suggested in the answer by Seçkin).
Though I must add that as a user I would resent an application doing that to me. Unless it's a nuclear missile launch control application (or something with similarly drastic consequences of a user mistake), I'll just uninstall it.
If I were you, I would create a semi-transparent rectangle which spans entire screen to achieve this effect. It is similar to see behind blurry glasses: World is not blurred, just glasses make it perceived blurry.

MFC mouse move/leave, hover on button [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to change background button when mouse move or mouse leave or click on button. I write my app in MFC.
Please help with demo/sample.
How to track mouse movements? See here
How to change the bitmaps of the MFC buttons? See here