EzDevInfo.com

sprite.js

An efficient javascript sprite animation framework

How to extract part of this image in Java? [closed]

I have this sprite sheet:

Pacman sprites

How can I read this image file to extract part of it to be used as a sprite ?


Source: (StackOverflow)

Javascript Sprite Animation Library for Canvas Tag

Can you point me to a good Javascript sprite animation library using the HTML Canvas tag?

A few Google searches only turned up some non-canvas projects. I am looking for something clean and simple.

Thanks.


Source: (StackOverflow)

Advertisements

Emulating old-school sprite flickering (theory and concept)

I'm trying to develop an oldschool NES-style video game, with sprite flickering and graphical slowdown. I've been thinking of what type of logic I should use to enable such effects.

I have to consider the following restrictions if I want to go old-school NES style:

  • No more than 64 sprites on the screen at a time
  • No more than 8 sprites per scanline, or for each line on the Y axis
  • If there is too much action going on the screen, the system freezes the image for a frame to let the processor catch up with the action

From what I've read up, if there were more than 64 sprites on the screen, the developer would only draw high-priority sprites while ignoring low-priority ones. They could also alternate, drawing each even numbered sprite on opposite frames from odd numbered ones.

The scanline issue is interesting. From my testing, it is impossible to get good speed on the XBOX 360 XNA framework by drawing sprites pixel-by-pixel, like the NES did. This is why in old-school games, if there were too many sprites on a single line, some would appear if they were cut in half. For all purposes for this project, I'm making scanlines be 8 pixels tall, and grouping the sprites together per scanline by their Y positioning.

To clarify, I'd be drawing sprites to the screen in batches of 8x8 pixels, not 1x1.

So, dumbed down I need to come up with a solution that....

  • 64 sprites on screen at once
  • 8 sprites per 'scanline'
  • Can draw sprites based on priority
  • Can alternate between sprites per frame
  • Emulate slowdown

Here is my current theory

First and foremost, a fundamental idea I came up with is addressing sprite priority. Assuming values between 0-255 (0 being low), I can assign sprites priority levels, for instance:

  • 0 to 63 being low
  • 63 to 127 being medium
  • 128 to 191 being high
  • 192 to 255 being maximum

Within my data files, I can assign each sprite to be a certain priority. When the parent object is created, the sprite would randomly get assigned a number between its designated range. I would then draw sprites in order from high to low, with the end goal of drawing every sprite.

Now, when a sprite gets drawn in a frame, I would then randomly generate it a new priority value within its initial priority level. However, if a sprite doesn't get drawn in a frame, I could add 32 to its current priority. For example, if the system can only draw sprites down to a priority level of 135, a sprite with an initial priority of 45 could then be drawn after 3 frames of not being drawn (45+32+32+32=141)

This would, in theory, allow sprites to alternate frames, allow priority levels, and limit sprites to 64 per screen.

Now, the interesting question is how do I limit sprites to only 8 per scanline?

I'm thinking that if I'm sorting the sprites high-priority to low-priority, iterate through the loop until I've hit 64 sprites drawn. However, I shouldn't just take the first 64 sprites in the list.

Before drawing each sprite, I could check to see how many sprites were drawn in it's respective scanline via counter variables . For example:

  • Y-values between 0 to 7 belong to Scanline 0, scanlineCount[0] = 0
  • Y-values between 8 to 15 belong to Scanline 1, scanlineCount[1] = 0
  • etc.

I could reset the values per scanline for every frame drawn. While going down the sprite list, add 1 to the scanline's respective counter if a sprite gets drawn in that scanline. If it equals 8, don't draw that sprite and go to the sprite with the next lowest priority.

SLOWDOWN

The last thing I need to do is emulate slowdown. My initial idea was that if I'm drawing 64 sprites per frame and there's still more sprites that need to be drawn, I could pause the rendering by 16ms or so. However, in the NES games I've played, sometimes there's slowdown if there's not any sprite flickering going on whereas the game moves beautifully even if there is some sprite flickering.

Perhaps give a value to each object that uses sprites on the screen (like the priority values above), and if the combined values of all objects w/ sprites surpass a threshold, introduce slowdown?

IN CONCLUSION...

Does everything I wrote actually sound legitimate and could work, or is it a pipe dream? What improvements can you all possibly think with this game programming theory of mine?


Source: (StackOverflow)

When is a CSS Sprite too large?

Is the main purpose of sprites to reduce http requests made to the server for graphical elements on a page? Or do you want to try and fit as many elements to the sprite as possible.

I guess what I'm asking is: when is the sprite too large?


Source: (StackOverflow)

Can I add color to bootstrap icons only using CSS?

Twitter's bootstrap uses Icons by Glyphicons. They are "available in dark gray and white" by default:

Picture-58.png

Is it possible to use some CSS trickery to change the colors of the icons? I was hoping for some other css3 brilliance that would prevent having to have an icon image set for each color.

I know you can change the background color of the enclosing (<i>) element, but I'm talking about the icon foreground color. I guess it would be possible to inverse the transparency on the icon image and then set the background color.

So, can I add color to bootstrap icons only using CSS?


Source: (StackOverflow)

Changing the Coordinate System in LibGDX (Java)

LibGDX has a coordinate system where (0,0) is at the bottom-left. (like this image: http://i.stack.imgur.com/jVrJ0.png)

This has me beating my head against a wall, mainly because I'm porting a game I had already made with the usual coordinate system (where 0,0 is in the Top Left Corner).

My question: Is there any simple way of changing this coordinate system?


Source: (StackOverflow)

XNA 2D Camera Engine That Follows Sprite

What is the best way to create a parallax effect in an XNA game? I would like the camera to follow my sprite as it moves across the world, that way I can build in effects like zoom, panning, shake, and other effects. Anybody have a solid example of how this is done, preferably in a GameComponent?


Source: (StackOverflow)

Looking for a good Image Sprite generator tool [closed]

I looking for a decent Image sprite generator. I tried http://spritegen.website-performance.org/ but it's not "smart" enough to handle multiple image dimensions and merge them with few blank spaces between images.

Any suggestions???


Source: (StackOverflow)

how to obtain a CCSprite's width and height in cocos2d for iphone

That's the question xD

Given an instance of a CCSprite in cocos2d in iphone, what method can I use to obtain the image width and height?


Source: (StackOverflow)

How do I show sprites in the border on C64?

I've seen cool C64 demos showing sprites in the border area of the screen. It shouldn't be possible; I think they managed to fool the graphics chip somehow. How exactly did they do it?


Source: (StackOverflow)

libgdx difference between sprite and actor

I'm just going through the javadoc and various tutorials on libgdx and I'm at the stage of trying to figure out differences between various concepts that seem similar to me or provide similar capabilities in libgdx.

At first I thought scene2d was about creating interactive items such as menus, etc but various tutorials I'm reading use scene2d/actors for the main game items (i.e. the player, etc) and others just use sprites.

What exactly is the difference between using Sprite and Actor (i.e. scene2D) in a game and when should you choose?

Thanks.


Source: (StackOverflow)

How do I test if a property exists on a object before reading its value?

I'm attempting to read a property on a series of Sprites. This property may or may not be present on these objects, and may not even be declared, worse than being null.

My code is:

if (child["readable"] == true){
    // this Sprite is activated for reading
}

And so Flash shows me:

Error #1069: Property selectable not found on flash.display.Sprite and there is no default value.

Is there a way to test if a property exists before reading its value?

Something like:

if (child.isProperty("readable") && child["readable"] == true){
    // this Sprite is activated for reading
}

Source: (StackOverflow)

SpriteKit's SKPhysicsBody with polygon helper tool

I wonder if there is a tool that could be used for easy generation of complex physics bodies in SpriteKit. I would like to have a volume based physical bodies with polygon-type shapes. SpriteKit allows to create such bodies with that method:

+ (SKPhysicsBody *)bodyWithPolygonFromPath:(CGPathRef)path

Unfortunately it's time consuming task to generate such paths manually, and it could be problematic when testing. There is a SpriteHelper application that allows you to define body shape within easy-to-use visual editor, but this app can't export paths that could be used here. It was made for cocos2d and it does a lot of things like texture packing etc. that I don't need and I can't use with SpriteKit. Does anyone know a solution that will allow to define CGPath's easily or maybe even auto-generate them from png images with alpha channel? Although auto-generation feature from my experience would need optimization, because the body shapes should be as simple as possible when textures could have more complicated shapes.


Source: (StackOverflow)

Remove border around sprite image in Chrome

First time using this technique, seems that regardless what attributes I try to assign the border will not go away in Chrome. Other browsers are fine. I've tried outline:none, border:0; etc, etc. Also tried adding a colored border around the image, and noticed the the black border was still there within the colored border. Doesn't seem to want to go away.

Work-around's or advice much appreciated.

.share-link {
display: block;
width: 41px;
height: 32px;
text-decoration: none;
background: url("link-icon.png");
}

.share-link:hover {
background-position: -41px 0;
}


<a title="Share this Link" rel='nofollow' href="#"><img class="share-link"></a>

Source: (StackOverflow)

Is there a 2d sprite library for webgl? [closed]

I am looking to build a 2d game using WebGL. I want the hardware acceleration that WebGL provides and I cannot get this from the 2D canvas context in the canvas tag.

With that said, is there a tutorial on creating 2D sprites using webGL? Or, better yet, is there a 2D sprite library for WebGL? Ideally, I'm looking for something like cocos2d ported to WebGL.

Not surprisingly, all of the demos, tutorials and libraries I have found for WebGL focus on 3D manipulation. Are there any WebGL libraries that support 2D sprites?


Source: (StackOverflow)