How to make a sort of scratchboard in flash? - image

I was wondering if someone could teach me how to make a scene in flash where you have an image on top of the other, and you can scratch the top one off to show what's below.
Kinda like those prize cards where you have to scratch the silver thing to see if there's a prize below.
Anyone has any idea if this is even possible in flash?

Yes it's possible, here is one example. I'm sure there are others.
The concept is that you use a mask to hide the image. Then use a mouse move event listener to draw on the mask as the user mouses over the object. Parts of the mask that have something on them (ie: the stuff you're drawing in the mouse move listener) will then reveal the underlying object that was being masked.

Related

Create pop menu Sims's style when click on Character in Unity3D

I'm trying to build a game that uses a concept from the known game "The Sims". Right now I'm building the AI for a 3d Character, and I need the player to be able to tell where the character should go or do. I want to know the best ways to create a pop up menu with animations, kind of to show some choices, so that when the player clicks over the 3d Character he can pick wherever he wants to do. I know this must be using UI elements under a Canvas that's placed over the player. However I can not have 2 Canvas in a Scene and I don't know how to fix them to the character so that it moves with him. Thanks in advance.
Here you can see what I mean, this is the Sims Game
You have two main approaches here:
1) Use a world space UI.
2) Use a screen space UI and position it in real time using a worldspace to screen space transformation.
Both of these topics will expand substantially when you approach them, so it's not possible to give any more specifics from here.
Having played the Sims a bit before though, I would suggest you use a world space UI system if you're chasing the same style as them.
You can have as many canvases as you want. To control levels of canvases (which one is on top) you use "Order in Layer" parameter in "Canvas" component of your chosen Canvas. The lower the number is the higher interactivity and visibility your canvas has.
You can create one canvas ant parent it to you character. AS the canvas will be smaller your should play with these parameters to get the resolution you want (don't over do it):
To make canvas always facing the camera you should give Canvas a new script, with a command:
canvas.transform.LookAt(camera.transform);
To control canvas' visibility you may use this code line:
canvas.enabled = bool;
Where bool is false when you want to hide it and bool is true when you want to show it.
In the "Sims" the visibility comes with animation which you may do also, but I would leave it after I did all the functionality.

Xcode image/pixel manipulation realtime

Hi I'm looking to do the following:
For a game, Create some effects based on the current view.
The code needs to grab part of a view then manipulate it.
One I need is "glass", so when the character walks behind the glass(or where the glass should be), the code will grab the image behind the glass and stretch it and reprint it where the glass should be, to give the effect of walking behind a lens.
What is the best way to do this?
I've never tried any thing like this before, so any help will be great!
I think you're asking about the image manipulation capabilities of the cocoa framework, in which case I reccomend looking into CoreImage:
http://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185
The NSBox draws on top of the player view, the resulting composition gets a CIFilter (distortion) applied to it before drawing.

Gamesalad actor image mask with wiping mouse input

I've tried searching for 'actor mask with gamesalad', 'actor image mask with game salad', and 'image mask with gamesalad', but can't seem to even find the fundamentals for creating a mask on game salad.
Basically, I would like my final result to look like something splats on the screen, and then the player wipes it off with their finger which is where the mask part comes in.
I'm not 100% sure what you're asking but I think i know what you're getting at. Do you mean that you want to erase the part of a picture where a users finger has been? Abit like some sort of finger eraser tool?
If so I hate to say that Gamesalad doesn't do this at the moment. I had a quick play to see if it could be done with image modes but didn't have any luck. The only way I could think that you could do it is by having a solid colour background (which may not be in favour of you app design) and then spawning a 1x1pixel sized actor every 0.01 second when the touch is pressed on location of the finger. This would create the illusion that an item is being erased.
Hope that helps.

Cocoa: Custom control not limited to window frame - how to start?

I want to build a custom control that would work like this:
You have a kind of NSButton with an image.
You click the button and than appears a big square with a grid of photos.
You click one of the photos and it is set up as new image for the button. (square dissapears)
Now, how to draw this big square with photos if I want it not to be limited to window frame?
I mean, if the button was close to window border the square is going to be partially outside window. I would also like to add some shadow to the square and an animation for opening/closing.
One important thing: I want to be able to draw not only a square but any other simple shape (circle)!
This isn't really a drawing question so much as a general custom views question. It's important to make that distinction.
I'll describe this in terms of rectangles to give you the general idea*. You should make sure you understand the view hierarchy and view geometry in Cocoa. Without this important requisite knowledge, you'll remain dead in the water.
It's easy to set an NSButton's image, so I'll leave that to you. Your button's action, however, would tell some controller to show the "image picker" for the given button. Your image picker would be some type of borderless window with an image list inside. The image picker could be an IKImageBrowserView (you'll have to enable Image Kit in Interface Builder for this control to appear), which gives you an iPhoto-like grid of images (with/without titles, different border types, etc.).
An explanation of the operation of this controller and how it creates the window, manages the selection, and sets the button's image is very broad so if you get hung up on any of those steps, you'll need to create a separate question for each problem, otherwise this answer would have to be an instruction manual for writing your app for you.
* Your problem is a little more difficult because of your desire to have differently-shaped "popup windows" ... you'd have to make sure your available photos fit neatly within the shape so none of them are cut off. Armed with the basic knowledge of view geometry, I'll leave this to you as an exercise. A hint: you can use a borderless, transparent window to host a view that draws itself in any shape you please.

Qt - Drawing a Rect/Frame out of a bigger Pixmap image

I've been banging my head about this seemingly easy task and I could really use some help.
I have a wide Image loaded in the gui (using the designer..) and I want to be able to draw only a portion of it, a rectangle.
I need to be able to change this rectangle position over the large image, in order to draw a different part of the larger image at will. In this process the rect must maintain its size.
Using the Ui::MainWindow object I'm able to access the label holding the image and a solution that involves using this option is preferred (in order to keep up with the rest of the code I've already written )
Any solution will be much appreciated :)
Thanks,
Itamar
I would definitely (for ease of use) just place an empty label as placeholder in Designer.
Then implement the paintEvent for this label (delegate it to your own method). You'll have also have to look into QPainter, QPixMap, etc... Should be doable based on these hints and the documentation.
If you want more, I suggest you provide a small code snippet to work upon.
If you want to do this more or less purely through designer, you could put a QScrollArea where you want the portion of the image to appear. If you set the scroll area's scrollbar policy to be never shown, you can then manually change what part is visible via the scroll area widget. However, this would probably be more complex that creating a derived widget and reimplementing the paint function.

Resources