How to load bitmap from sprite sheet in easeljs - easeljs

I am using easeljs library. I created a sprite sheet using sprite generator with all the assets(buttons,background images,icons, etc). I got a sprite sheet and a css file (contains co-ordinates, dimensions). I need to load every images in the sprite sheet.

I answered this here on the CreateJS site:
The best way is to preload the images using PreloadJS (http://preloadjs.com). There are a bunch of examples in the PreloadJS GitHub that should help with that. Additionally, 3 of the EaselJS demos use PreloadJS (Game, SpriteSheet, and Transform).
Note that the images will automatically load one they are used - and they will show up once loaded, as long as you are updating the stage.

Related

How can I load a Gigapixel image as a material in SceneKit?

I’m trying to create an AR image to project on a wall from a Gigapixel image. Obviously Xcode crashes if I try to load the image as a material. Is there an efficient way to load only parts of the image that the user is looking at?
I'm using Swift 4.
This may not do exactly what you want, and you might need to roll-your-own way of parsing and passing data between Core Animation and SceneKit, but this is native, and is designed to handle large images and texture data sources, and feed them out asynchronously, and/or on a demand based basis:
https://developer.apple.com/documentation/quartzcore/catiledlayer

how to create dynamic UI that adjust itself to current screen dimensions after loading?

I have created a level editor using new UI system in Unity3D.
Using Level Editor:
I can drag the ui elements,
I am able to save them in scriptable objects
But how could i save and load them at runtime?
I mean, if i create a level with some {width x hight} resolution and if i load it on different resolution, then the whole UI positioning get distorted.
How could i anchor them correctly programmatically?
Any help would be appreciated.
There are good video tutorials about the 4.6.x UI here:
http://unity3d.com/learn/tutorials/modules/beginner/ui.
Especially for positioning the elements I recommend watching: http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform.
I suggest you learn how to use the anchor correctly first. If you want to change the position and size of UI element in a script you can do that through the RectTransform component. It offers functions like offsetMax,offsetMin and sizeDelta for position your UI element. The functions you need to use depend on your anchor setting.
as LokiSinclair said. You just need to Adjust the Scale that the new UI provided. It is the four Arrow on the Canvas of each Object and every UI object is inheriting their scale behavior from their Parent.

Loading in a tileset with c#?

I've got a very large tileset with over 200 different 64x64 tiles. It would be practical to load them in a C# script, I've tried the following (for-loop):
tileset[x] = Resources.Load<Sprite>("Sprites/Tileset/Tileset_" + x);
Where in my asset folder, Sprites is the folder where Tileset.png is. Tileset.png is sliced in a grid (64x64) in I see Unity has sliced all the tiles correctly.
Is there a way I can load them, and put them in a Sprite array (Sprite[]) in code? What would be the correct path?
Looking for correctness? Then batching is caring...
If loaded individually, each tile will cost you a draw call. I would recommend that you look at creating spritesheets to batch the loading and rendering or these tiles. We have been using TexturePacker to load images for our apps and displaying 200+ images at once with one load call, one draw call and great performance. Alongside the app to create the spritesheets, there's a Unity Plugin on the asset store to load and manage them.
Note: we use the pro version.
Otherwise you can just load all the resources at a given path with Resources.LoadAll

Draw on an image in iPhone app

I'm fairly new to iPhone app development. I'm trying to make a scrapbook app (for fun sakes) but I can't figure out how to draw on and add pictures to my template which is also an image file (and a UIView). Should I save my template as a pdf? Essentially I don't know how to add stuff to my template - for example draw shapes on it, add a text box, add a picture, etc
Please help!!!!!
No PDF needed. Check out Quartz 2D:
https://developer.apple.com/library/ios/#documentation/graphicsimaging/conceptual/drawingwithquartz2d/Introduction/Introduction.html
You create a context (e.g., via CGBitmapContextCreate), add you bitmap (e.g., via CGContextDrawImage), draw text (e.g., via CGContextShowTextAtPoint), etc.
Review the Quartz 2D introduction above, and then review some the Quartz 2D code samples. It's not hard, but it's not obvious, either. Just takes a few times to get the hang of it.

working with large sprite sheets on iphone

I am trying to use sprite sheet animation in my application.
The first POC with a small sprite sheet worked fine but as i change the sprite sheet to a bigger one, i get "check_safe_call: could not restore current frame" warning and the application quits.
A quick search revealed that this problem meant my app is taking too much memory or the image is too huge in dimension.
My image is 4.9 Mb and dimensions are 6720 * 10080 (oops!!). i read that iphone allows maximum 3 Mb image with dimensions up to 1024 * 1024. Also that the sprite sheet image dimensions should be a power of two.
So please let me know how i can use a sprite sheet this big.
One approach could be to cut the sprite sheet into many smaller sprite sheets and use them one at a time.
Please suggest if you know any other/better approach to accommodate bigger sprite sheets and whether the problem with my sprite sheet is size (4.9 Mb) OR dimensions (6720 * 10080).
(Just FYI, i am not trying to play a movie so using MP4 file instead is not an option for me. i need to animate the sprite sheet based on accelerometer input and i have been able to achieve that in my POC with smaller sprite sheet.)
Thanks,
Swapnil
You should cut up the sprite sheet into multiple textures as you describe. The iPhone's memory and graphics chip simply can't hold an image/texture of that size in memory at once. By splitting up the sprite sheet it will deal with loading/unloading the appropriate textures into memory when you use them.
You might also consider optimizing the image format. Using the PVRTC format can save a huge amount of memory, but it is only well-suited to certain kinds of images. See this Apple page for more information.
definitely keep it within powers of 2. also, keep the sprites within the spritesheet in containers that are powers of 2 (say, you have a 17x31 sprite... put it in a 32x32 container). the problem with your sprite sheet is both the 4.9mb and the dimensions. i would consider using adobe fireworks or pngcrusher to bring the size of your sprite sheet down considerably.
mike weller's right about splitting the sprite sheet up (you simply cannot max 1024). i think the best bet would be to reorganize what you're doing with your sprite sheet into elements (though it's tough to say without knowing particulars). only things that move should have multiple frames. overlay those over a background (from the same spritesheet) by calling there location on the spritesheet and tossing them into play.