I am creating a game where you need to catch images moving across the screen using another image that you can move up and down the screen. Once you catch or contact one of the moving images that image is supposed to disappear and another image is supposed to spawn on top of the position of the catcher image. All of this works fine except for the fact that when the new image spawns it dose not spawn in the CURRENT position of the catcher image but in the catcher positions starting point. So how can I find the current position of the catcher image and tell the new image to spawn there. Thanks
If your image is an SKSpriteNode...
let whereTheImageIs = image.position
Related
I have an app where users can scale and position images in a number of ways. They can drag an entire layer of images around, scale that layer, drag around individual images inside the layer, and scale those individual images.
For some unrelated functionality, I need to generate the image coordinates that a user is pointing to on a given image (ie (0,0) for the top left & (width,height) for the bottom right), independent of how much it has been moved around and scaled. Is there a built in method for tranforming an absolute mouse position to it's relative position on an image (and vice versa) that takes into account any scaling/panning? I have started building my own methods for this tranformation but before I got too deep I wanted to see if it was already built in somewhere that I'm not seeing.
Konva doesn't have such methods yet. You have to implement them manually.
You can subscribe to this related issue: https://github.com/konvajs/konva/issues/303
I was trying to achieve the following functionality and wanted to ask for some help:
There are n barrels on the screen.
Randomly, a monster will pop up out of the barrel, and then go back down. I got this working, but I want to make a revision where sometimes instead of going up/down, a monster will jump out of the barrel along an arc, and land somewhere on the ground nearby. After some time, he will jump back and follow the path in reverse back into the barrel.
My original code workedby simply created a barrel i.e. addChild(barrel) to the scene, added a cropping node over it i.e. addChild(croppingNode) where croppingNode's position is over the barrel, and then add the monster to the cropping node as a child (croppingNode.addchild(monster))
This worked perfectly - the monsters come up, and then slide back down and the node hides their lower half so they appear to have went back inside the barrel.
My revision was to have a monster randomly jump out of the barrel on an angle and land on the ground, but the problem is because the monster is added to the cropping node, it is clipped if I try to move it outside the bounds of a cropping node.
If I add the monster outside of the cropping node, I believe he will no longer be cropped, correct?
What would be a way to achieve something like this? Use a larger cropping node image that is larger than the barrel and accounts for his arc onto the ground?
Thanks!
I am creating an application in cocos2d using sprite builder where a user clicks a picture from the camera which is then converted into a jigsaw puzzle. I have cropped and converted the image into a puzzle of four images by masking and saved it into an array successfully. I now want to add all the four images into the same sprite. At the moment I'm adding the images to the sprite with a for loop but I end up overwriting the previous images and the end result is a single image in the sprite. I'm not sure how to add multiple images to the sprite (or multiple sprites to the screen. Whichever works). Please let me know how can I achieve this.
Thanks in advance.
Regards codePassion.
I'm trying to make a ViewController that presents info from a webpage like this:
However, I'm confused on one thing. How did they get the imageView to display an image that's cut off at the corner, i.e. not rectangular? Do you think they created that player card in Photoshop and used it as the background for the imageView image, or did they create it programmatically?
I wonder because the image is behind the picture of the bear, so I imagine if they created the background in Photoshop, how would they get the image behind the bear head? They can't have just created the card with the player's picture as part of it, then loaded the whole image because if they traded the player, because I'm sure they pull the player info and picture from the web so they can have a card for all players, even if they trade or acquire a new player mid-season, without having to update the app (and add the finished image to images.xcassets).
This can be composed from two CALayers at runtime. Put the picture on the bottom layer; the picture can come from anywhere - the web, the bundle, etc. the image source could be dynamic.
Put another CALayer on top, with the frame rendered with opaque colors, and a transparent cut-out for the picture in the middle:
There are a bunch of ways to do this. A simple and flexible way to do it is to create a CAShapeLayer that's the same size as the image view, with it's origin at 0,0, and add it as the UIImageView's layer's mask.
You'd create a filled UIBezierPath that maps out the part of the image you want to show, and install the bezier path's CGPath into the mask layer's path property.
The result would be that the image view is cropped so that only the part inside the shape is drawn.
In my game i am creating and transition random building at run-time listener. but that images are too long.when i am creating images it get stuck on my game.how to fix the problem.images are mostly in 15-30 KB.
If the images are too long and go off the screen try using xScale and yScale to scale the images. Also remember that images are layered in the order that you place them in your code. For example:
display.newImage("image1")
display.newImage("image2")
In this example image2 would be placed about image1.
Also keep in mind that if you want to remove images from the screen you have to run this code:
image1 = display.newImage("image1.png")
image2 = display.newImage("image2.png")
display.remove(image1)
display.remove(image2)
In a runtime listener, you have to make sure to remove the image every frame:
local function func1()
if image1 then display.remove(image1) end
image1 = display.newImage("image1.png")
end
Runtime:addEventListener("enterFrame", func1)