I'm making a game with cocos2d-x HTML5.
On one layer there are two images which is almost same but have several different area and when I click one of them, if the clicked area of two images has a different pixel, I want to add a sticker to the same location to both images.
I want to ask that how can i compare the image pixel on cocos2d-x HTML5?
and how do I make the click event to place the sticker?
Probably CCImage class will help you.
What I suggest is, as you already have 2 images, and you have know the different area,
you can create a plist Dictionary recording the area position and size.
In your game scene, you can add transparent touchable Sprite created from your config list file, and set a color to it when it is touched.
Related
I tried looking for this in search, but it is a lot of individual things packed together. What I am looking to make for my students is an interactive display of the triangle of exposure on a camera.
It has three sliders that show what happens with different settings. One is ISO (controls dark and lightness), another is shutter speed (which controls background blur/depth of field), and aperture, which controls motion blur. I was able to make a slider that effectively changes the test image in darkness. I am currently working on the slider for shutter speed.
I am wondering if the interaction between the sliders would be better accomplished through switching between PRE-PHOTOSHOPPED images by substitution, or using AS3 to accomplish changes on the fly. For instance, if they move the sliders for shutter speed and ISO at the same time, it gets dark AND has background blur. do I need to pre-photoshop every possible option, and switch symbols, or can I do it interactively with AS3?
Here is my code:
import flash.utils.getDefinitionByName;
import fl.motion.Color;
import fl.events.SliderEvent;
var myImageName1 = "blurback.jpg";
var classRef:Class = getDefinitionByName(myImageName1) as Class;
var instance:MovieClip = new classRef();
var c:Color=new Color();
var color = "#000000";
ISO.addEventListener(SliderEvent.CHANGE, sliderChanged);
aperture.addEventListener(SliderEvent.CHANGE, apertureChanged);
function sliderChanged(evt:SliderEvent):void {
tintClip();
}
/*
The 'setTint' method of of the Color class takes two parameters: tint
multiplier,
(a number between 0 and 1), and a tint color.
The tint multiplier, is determined by the positon of the slider, 'val'
and equals val/100.
The tint color, 'color', is determined by the color selected
in the picker.
*/
function tintClip():void {
var val:Number=ISO.value;
c.setTint(color,val/10);
kitty.transform.colorTransform=c;
}
function apertureChanged(evt:SliderEvent):void {
gotoAndPlay(2);
/*kitty.addChild(instance);*/
}
I am still experimenting with the second slider, so the gotoand play is a work in progress on substituting a pre-background-blurred image when the slider is slid.
Here is a pic of the final image, with the sliders named appropriately.
link: Final image
One is ISO (controls dark and lightness), another is shutter speed (which controls background blur/depth of field), and aperture, which controls motion blur.
ahem
All of the three settings influence the exposure value, making the image lighter or darker. Additionally:
ISO has an effect on noise in the image, which can severely degrade image quality
shutter speed is actually the one influencing motion blur and visibility of camera shake
aperture (among other things) influences depth of field
I am wondering if the interaction between the sliders would be better accomplished through switching between PRE-PHOTOSHOPPED images by substitution, or using AS3 to accomplish changes on the fly.
Neither of them is a good option.
Recreating the effects of the different settings with As3
realistically will take a lot more time (if possible at all) than simply having several images.
Recreating the effects in photoshop is probably easier as it is equipped with dozens of photo editing tools, but you'd still have to create the effect realistically.
Instead of photoshopping things, show your students the real deal:
Setup a subject in front of a background to show possible changes in depth of field
Include a solid color area where noise will be easy to see. This could be the background.
Add some motion, to show motion blur. A fan as a subject comes to mind.
Then take those images by varying the settings. Sure, with 5 different values each, you get 125 images. But you get real world example photos.
Keep the resolution low, so that the image files aren't too big. Process them by reducing resolution further to a reasonable size, say 800 x 600.
With the images created load them into your swf with the Loader class. The easiest way to keep track of them is to have a three dimensional array of Loader objects. Each slider then manipulates one index to change the image.
I made a frame give a title to it and I added buttons to the frame using clojure. I am not able to guess how to add background image to my frame.
I have a background image stored in the drive, I tried adding the background image in doto panel but it showed series of errors.
Help!
You need to go a little bit more deep than that. paintComponent of JPanel is your entry point. Inside paintComponent you can load the image in draw it.
After that, you call getContentPane().add(new YourJPanel()) of your JFrame.
One a side note. If you are planning to do Swing development in Clojure, did you consider: Seesaw?
I'm a bit confused about what kind of tile I should choose to make my scenario work.
Scenario is as follows: my application supports small and medium tiles. By default in both these modes it shows an app icon on transparent background but user can choose a particular image to be a tile cover. When tile is covered with image I don't want it to flip or move - just a static image with app name on top of it.
I've tried TemplateCycle with app icon as default and user's selected image as an alternative but cycle tile moves these images up and down all the time and I don't want that. I've was considered TempalteIconic but it turned out it only supports images with transparent background so no option for user's image. So what kind of tile should I choose?
Use a normal fliptile but don't set anything(text, image) on the back. It won't flip if you do that.
Is it possible to have a single SWF file with multiple "stages" appearing at different parts of the page and sharing data?
What I'm trying to do requires sharing big amount of data (byteArrays of image data) that cannot be shared through LocalConnections or via JS (very slow) so I'm trying to avoid the "sharing" part and somehow do it in a single SWF. Problem is, those images need to appear on different parts of the page thus I'm stuck.
There is only one Stage in swfs - the Stage is effectively the background; and you cant have more than one background.
"Problem is, those images need to appear on different parts of the page" - why cant you adjust the position of the images?
Use swf 100x100 % of browser window with transparent bg (wmode='transparent'), load images and place them in appropriate position. Main problem how to calculte coordinates for thumbnails... ^)
And flash with transparent bg very slow too...
I don't know if the title is misleading as the image I'm loading is actually a sprite image consisting of a multi-state button. I want to load this image and split it into several display objects (sprites?) in AS3, to create a SimpleButton with an over and down state.
Right now I'm just loading the image with Loader and URLRequest, and then creating a sprite from the loaded content.
Is this possible or is there any other way of doing this, without having to load two separate images?
Thanks in advance,
Pierre
There is. You can use the mask function of the Sprite class. First you set the mask to normalstate button part of the image,, and on mouseover you set the mask to the other state and on mouse down you set the mask to the clickstate button part of the image
Please mark as answer if this helped.