I always want it to hover to. background-position is a property with multiple values. Completely agree that this should be in the spec. One my jQuery plug-in is relying heavily on background positioning and so far it is performing well everywhere I've tested. Bob (#2), this is a cosmic law which also applies when inserting a piece of paper in the printer for duplex printing. The HTML image position code information below will help you fine tune the placement of an image … When needed, I create an Image on my UI canvas and tween it to 0, 0, 0. Thanks again for inadvertently saving me hours I'd have otherwise spent doing countless Google searches; keep blogging! Instead I had to resort to much more bloated code for a card game that utilized sprites http://www.russellheimlich.com/blog/ie-gets-a-css-rule-right/. And indeed, hover/active states is another good reason to have X/Y support. Here's where it saves space: .icon { background: url(sprite.png) 0 0 no-repeat; } To get sprites moving, we will change their position using a game pad event. I was already paranoidly afraid that my goldfish had managed to cause all my computers to malfunction in some most bizarre ways. I find background-postition-x and y very useful for sprites. The next call relates to animation. Plus, managing those sprites is a nightmare. We can use those events to change sprite location, and to make the sprite move. Now that we have seen how this works for the four directional buttons, we can use a shorter method to handle this. Every now and then I look at using background-position-x and background-position-y but can never seem to find a definitive and up-to-date resource. Describe the difference between changing position and changing velocity. I'm not going to try a fresh install or anything like that because if it happens to me, it's going to happen to other visitors so I have to assume it's broken. Wouldn't it be great to just add in an extra line in bidi environments where we tell the background of all sprites to be positioned on the right instead of the left? The command AddSpriteAnimationFrame’s first parameter is the ID number of the sprite. Interesting is, that setting background position in JavaScript using jQuery, background positioning works just fine for me even in Firefox 3.0.10 and also in Opera 10.00. I concur Jonathan. Mileage may vary. :-). void Update() { transform.position = Vector2.Lerp(transform.position, end.position, Time.deltaTime); } As we talked about in the beginning the code takes the sprite from transform.position to end.position by Time.deltaTime amount. Admittedly, that didn't save us any bytes and for this reason alone, I can see why the W3C denied the inclusion of this into the specification. Making a change (based on a change to the underlying art) is especially frought with danger. // Example that loads sprites from a texture in the Resources folder // and allows them to be chosen by the selection button. It has become a de facto standard and it's exclusion from the W3C specification doesn't diminish it's usefulness. Finally, here's the support table for which browsers support background-position-x and background-position-y. #c:active { background-position: -60px -60px; }. The x position block is a reporter block and a motion block.The block holds its sprite's x value, the sprite’s horizontal location on the stage. A sprite image is simply a single image file (in .jpg or .png) which has multiple drawings within that single image. That's it. However, let's take a look at internationalization. #c:hover { background-position: -30px -60px; }, #a:active { background-position: -60px 0; } Of course, we could optimize this like so: However, given access to separate X and Y values, we could optimize it like so: Admittedly, that didn't save us any bytes and for this reason alone, I can see why the W3C denied the inclusion of this into the specification. But I'd still like it in all browsers, pretty please! Do you want to contribute? I'm also in the middle of a food adventure and I like whisky. Mr Snook, Thanks for this little tips. Shame it didn't pass w3c specifications. To make it appear that the sprite is walking (or flying, or whatever it is your sprite is supposed to do), you need to change its position on screen when the appropriate key is pressed. By calling this command we’re telling AGK to add “item0.png” into sprite 1s animation sequence. Because my testcases fail for both the -moz-background-position-* and background-position-* – and the error console flags them as errors (tested with both fx 3.6 and the latest Minefield builds). Problem is, I need to choose the correct screen position of another image, but can't seem to find the correct values. When the velocities of a sprite are not zero, then the sprite will be in motion. I can never remember whether X or Y comes first, and I always resort to guessing randomly. Describe how events can be used to run code using an example. Instead, without the ability to separate X and Y values, all sprites need to be redeclared for RTL environments. You can multiply Time.deltaTime with a number to make the movement go faster. Activity: Sprite Motion and Events. In these scenarios, where an icon is positioned on the left of some text in a left-to-right environment (LTR), the icon should now be positioned on the right. We need it. The ||sprites:stay in screen|| block is in the Sprites menu. Tried loading it twice. The second parameter is the ID number of the image. We will also see how to give a sprite a speed of motion, or velocity. Use of 'inherit' appears to work fine, and inherits the non-hover position without having to re-write it. Sorry, comments are closed for this post. Motion is the change in position. To save myself the trouble in the future, I'm documenting it here. There's no need for a "use case". Yeah I'm in your corner and have been clamoring for this as well. If we have a positive X velocity, for example, then our sprite will continue to increase in X, making it move to the right across the screen. My apologies for poor testing. #b { background-position-y: -30px; } comments, feel free to. Add images in the Animation Tab. Hi. Velocity is the rate of change of our position - in real life, this is often measured as kilometers per hour or miles per hour. Such images are called sprite sheets. I can't count how many times I've wanted to use this when I'm using the sprite technique, not realizing that it's now widely supported (Firefox 3.6 seals the deal). #b { background-position: 0 -30px; } You forgot one selling point: Finally being able to know, without having to look it up for the 4,038th time or guess blindly, where the X-value and Y-value go. Edit template of this page on GitHub, Create a new project and name it “motionLR”, Add additional code to control the up and down (, Create a new project and name it “velocityLR”, Create a new project and name it “motionShortMethod”, Start with motion (short method) example above or similar code, Change the key pad motion to use the discovered block by placing it in, Make the sprite stay in the screen boundary, Create a new project and name it “flipImage”, Note use of the function called “flipHorizontal”.