Generating Normal map from a Image with a given Albedo map I am working on a research problem part of which involves generating normal map from a given image of a rusted object. I searched the internet for techniques to achieve the above and apparently crazybump is mentioned a lot. I tried it but it didn't produce the desirable effects. Also I am looking for a method which draws inspiration from an existing research paper not some closed source software. I turned my attention to the technique described in the this paper. Results from this technique are satisfactory for normal objects because of bias in the training data but it doesn't work very well in the case of rusted objects. After this I focussed my attention on generating Albedo map (the above problem would become more solvable if Albedo map is obtained). Fortunately I am able to generate pretty good albedo maps for images of rusted objects. I used this paper's approach to generate Albedo maps. Now I want to know a good technique to get Normal map given an image and it's corresponding Albedo map. To give you an idea of what kind of images I am working with I am attaching a sample. Links to research material would be really appreciated. Thanks!


sprite animation individual framerate When animating sprites I am taking the delta difference between frames and locking the rendering frame rate of the sprite animation to the delta time. float delay 1000.0f FPS float now SDL GetTicks() if(now sprite gt last update gt delay) render sprite frame This is causing flickering because the background is being drawn faster than the sprite. (my guess) If I draw as fast as the frame rate the flickering goes away. If I slow down the background rendering then the background flickers. By slow down I mean set the FPS to 30. I want to be able to slow down the animation for a single sprite. I need a better way to lock the frame rate for individual sprites. I can slow the entire frame rate down by delaying in the game loop but I want to be able to slow down a single sprite. Is this possible?


Art asset creation workflow question are there any neat ways to save your work and automatically export it to desired format? To be specific I have used GraphicsGale for pixel art sprites. The program saves its files in its own format (.gal, I believe), but the images in my game have to be .png. Saving it to .png loses information for GraphicsGale, like the palette. Manually keeping to seperate files impairs the workflow. Ideal would be that after every save, the original file is saved in one folder, and a .png export in another, awaiting runtime and packing. Any suggestion thoughts?


Geometry Shader and Stream Output with Directx11 I am having trouble trying to send verticies generated in the Geometry Shader to Stream Output. What I am trying to accomplish is to generate verticies from the Geometry Shader and store them to a vertex buffer so that I can use the vertex buffer to draw later. I read that I have to use the CreateGeometryShaderWithStreamOutput function to create a Geometry Shader that can send verticies to Stream Output instead of the rasterization stage. This is how I am trying to use it device gt CreateGeometryShaderWithStreamOutput(this gt mGSBlobSO gt GetBufferPointer(), this gt mGSBlobSO gt GetBufferSize(), so decl, 1, amp stride, 1, D3D11 SO NO RASTERIZED STREAM, NULL, amp this gt mGeometryShaderSO) I am getting an E INVALIDARG at this line. I am specifying D3D11 SO NO RASTERIZED STREAM because I think this means that I do not want to send data to the rasterizer but I am not sure. When I replace D3D11 SO NO RASTERIZED STREAM with a 0, I do not get this runtime error, but I do not get the result I want. How can I setup the geometry shader to store vertices to a vertex buffer in Stream Output?


How can I improve or replace my programmer art? Say I'm a programmer who has done his own sprites or 3d models which would fall into programmer ish kind of art. What steps can I take in order to improve or replace my own art?


Which camera angle is used for these sprites? I am trying to replicate these sprites But I am not managing to make sense of how it is done. The character is facing forward ( lt ), but you can see the front of its body instead of just the side. Why? Is the camera positioned diagonally? Or is the body bent, as in a fighter stance? Or a combination of both? Which exactly is the positioning perspective view I should use to replicate it correctly?


How do you make use of all texture units on today's graphics cards? I saw a review of the GeForce GTX 460 graphics card. It has 56 texture units. I'm not that knowledgeable about graphics effects. But, the ones I know use around 3 or 4 texture units. In this graphics card case, that would leave a lot of texture units idle. How are these graphics cards with so many texture units used?


How to determine the maximum supported level of anisotropic filtering for a graphics card In software, at runtime, (C if it matters), is there a way to find out the maximum level of anisotropic filtering supported by the graphics card?


Graphics for non Graphics Designers Are there resources for programmers with little to no graphics design talent, but still want to make good enough graphics for their own programs? I'm interested in both 2d and 3d computer generated graphics techniques, as well as free graphics repositories.


How to render infinite universe? I'm curious what are the best practices in game development industry to render 3d universe? To be more specific The data points are given and static. Each point has position, color and size The entire data set is much larger than available memory User should be able to "zoom out" to see bigger picture at once The most naive approach would be to split universe into cubes and render only what's visible. I'm not sure how in this scenario should I implement the "zoom out". Should I precompute cubes for each possible zoom level? Or maybe there are better approaches? I'm looking for technology agnostic solution.


Is there a sprite sheet creator that satisfies these requirements? I'm looking for a decent sprite sheet packer. Features Command line interface for Linux. Effective packing algorithm. Configurable padding between sprites in the sheet. Configurable fixed sprite sheet size (i.e. pack to many sheets). Duplicate sprites detection, preferably with some tolerance to allow for FP errors when packing rasterized vector images. Auto crop by transparent pixels (i.e. sprite is cropped when packed and it is correctly reflected in the data). Support for web graphics formats (jpg, png at least). Reasonable data output format (sprite sheet indes). Paid software is okay as long as the price is reasonable.


What's the difference between using hardware accelerated APIs and the OS's drawing API? On Windows, I can do drawing with the OS API without OpenGL or D3D. The code I am writing will make calls to a device driver and tell the GPU what to do regardless, right? How is using OpenGL different exactly? Do these libraries have code that will interact with the GPU differently than just the Windows API does?


what is order of implementation of matrix transforms? What is the meaning of Tr Sh Ro Sc M ? How is matrix M written to form the graphic transformation 1st Sc Scale, 2nd R Rotate, 3rd Sh Shear 4th T Translate ? Is the matrix M above written properly in a "post multiplcative" format" T Sh R Sc , but executed Scale, Rotate, Shear , finaly Translate ?


Gravity independent of game updates per second Edit Just for clarification, my sprite's 'movement' isn't the problem. If I set my Time variable to 4 seconds, then it will cross the screen in exactly 4 seconds regardless of logic updates rate per second, rendering rate per second or screen resolution. So I am pretty sure I'm scaling the sprite's movement correctly. What I'm pretty sure I'm not doing correctly, is scaling acceleration. Original Question I'm trying to implement gravity in my 2d platformer and am having a few problems understanding how to keep it consistent when I change my updates per second. Here's what I have. My Gameloop overview Currently, my gameloop renders at the maximum rate allowed by device and the updates are 'clamped' to an upper limit (At the moment, 60 per second). I am working on the assumption that most of the time, my game will have no problem hitting this, even if the actual rendering dips. Thus I am doing all of my calculations based Delta Time derived from this fixed 'ticksPerSecond' value. I don't know for sure that this will remain at 60, I may decide at some point during the development to lower this upper limit. My Gravity variable declaration and initial values At the moment, I have float spriteYTime 7f This is the (initial) amount in seconds that this sprite will take to move from the top of the screen to the bottom. float fallAccel .5 This is the value that will subtracted from he sprite's fall speed (To make it fall ever faster) float terminalVelocity 1.5f Cap speed at this rate (1.5 seconds) my sprite's position is worked out on dt as follows Delta time float ticksPerSecond 60 float dt 1f ticksPerSecond Velocity spriteYVel 1 spriteYTime Update position spriteYReal spriteYReal (spriteYVel dt) Convert to screen coordinates (will be drawn at this Y coordinate) spriteyScreen (int) (furmanYReal height) My Gravity code If my sprite's state is 'f' (meaning falling) then apply gravity if(sprite.getState('f') true) Calculate new position spriteYReal spriteYReal (spriteYVel dt) Convert to screen coordinates sprite.yScreen (int) (spriteYReal r.height) Reduce time by fallAccel amount amp update velocity value based on new time value (So sprite falls slightly faster this frame compared to the last spriteYTime fallAccel spriteYVel 1 spriteYTime Check that speed isn't faster than terminal velocity if (spriteYTime lt spriteVelocity) spriteYTime spriteVelocity The problem Now, this does work, but if I change my ticksPerSecond value, it goes wrong (it falls at different rates). I know that 'Earth Normal' gravity is approximately 9.8 meters per second per second, but this is measured 'per second' whereas I (think) I need to work with 'per frame'. This is where I'm getting confused. So, take this example If set my initial Time value to 4 seconds, then if it remained constant at this speed, it would take 4 seconds to reach the bottom, if I changed my ticksPerSecond, because the time value is worked out using delta, it would still take 4 seconds but if I apply 'fallAccel" to the Time value (i.e. subract it), it goes wrong when I change the ticksPerSecond value why? How can I get this to fall at the same rate regardless of the value of 'ticksPerSecond' any help in understanding this would be appreciated.


How can SpriteBatch use a single texture asset as multiple independent objects instances I'm using LibGDX to create a game, but I'm encountering a problem with SpriteBatch. Whenever two objects that use the same image for their sprite come onto the screen, the new object replaces the old object. So, for example, one ship will come onto the screen, and when a ship with the same sprite comes onto the screen, the old ship will disappear and the new ship will have all the damage and other characteristics of the old ship. I could always make multiple copies of the same image and put them in the assets folder, but that seems unnecessary. Does anyone have any ideas? Am I using SpriteBatch incorrectly? Edit Here's a couple of examples of rendering methods in the game loop. The method for rendering ships private void renderDoodad(Doodad doodad) if (!doodad.isDisabled()) batch.begin() if (doodad instanceof Enemy) batch.draw(doodad.getSprite(), doodad.getX(), doodad.getY()) Followed by some code about what to do if the ship is the player's ship. But the player's ship is rendering fine, so I left that out. Then there's the method for rendering shots private void renderShot(Shot shot) if (!shot.isDisabled()) batch.begin() batch.draw( shot.getSprite(), shot.getX(), moveDoodadY(shot, shot.getDirection().getVal() getApp().getGraphics().getDeltaTime())) batch.end()


Planet sized quadtree terrain precision I've been working on a planet sized and shaped terrain lib for a while (In webgl and Unity) and have a couple of working implementations Quadtree cubesphere and circular clipmaps . But both of them suffer from the same problem. In the GPU vertex shader I move the vertices to their correct location on the planet. But 16 bit floats can't handle values that go into the millions. So when you get close to any vertex in the terrain it jiggles from the GPU rounding errors. With the quadtree solution this is how I put vertices where they belong in the shader vec3 newPosition vec3(normalize(StartPosition.xyz (WidthDir position.x HeightDir position.y) Width) Radius) In the circular clipmaps I create a point at 0,0,1 and use two quaternions to rotate it to where it belongs (one for where the point is in the clipamp and one for where the clipmap should appear on the planet), then multiply it by the planet radius. But both implementations require the multiplication of the planet's radius the clipmap also has one quaternion with precision far higher than a 16 bit float, at ground level it will be a precision of 1 6000000 of PI . So does anyone know how to handle this problem on the GPU so that at least the points closest to the camera have position values close to zero and no large number multiplication? Or is the only solution to set the positions on the CPU and just do some math work to make sure the vertices on the side of the planet closet to the camera always have values close to zero?


Project 2d click touch onto 3d plane I have a 3d scene that contains an infinite plane that is NOT parallel to the camera (so every screen coordinate corresponds to a point on this plane in other words, there are no possible invalid clicks touches). I have all the information you'd expect to work with camera pos, dir, fov, aspect ratio, the 3d points defining the plane (either as a triangle, or as a normal distance), the view projection matrices that project it onto the screen, etc... I haven't found anything online that answers this in a straightforward way. Please no "use this or that library". Also, if you're going to say "invert the matrix", please give a way to go about doing that (I don't think the matrix is easily possibly invertable, as the "project to 2d" process involves the divide by w step, rendering the final translation between 3d to 2d non affine).


What is "ROAM" related to terrain rendering? I saw it mentioned on this question, but no one explained what it is.


Where can I find good designers animators for the graphics of a 2d game? Possible Duplicate Where to hire 2D sprite artists? I've got a little bit of experience in this field already, and I noticed that it's way better to look for animators than graphic designers, because games need explosions, looping sprite sheets, etc. But it would be even better if I could go somewhere and find people with experience in making graphic assets FOR GAMES, not for general markets. Is there some specialized site or something?


What do you use to create sprite graphics? Possible Duplicate What tools do you use for 2D art sprite creation? What do you folks suggest for creating sprite graphics and sprite sheets? I fiddle with pixelformer and tilestudio. Pixelfromer has a kicken interface, it is quick and easy to make graphics, but a bit cumbersom if you want to make a spritemap. Tile Studio is a interesting mix or tiles and maps, but it is a bit buggy and basic. The Adobe series, just don't really seem to handle tiny graphics well. (there is a previous posting of this question existing, but it is a year old and I was hoping for further updated input from the community)


Transformations between coordinate systems In a graphics engine, I have three three dimensional orthogonal coordinate systems, O, A and B. A and B are the result of two different transformations from O. I now want to calculate the transformation matrix R, which takes you from A to B. R should be the rotation and translation with respect to coordinate system A, not the original coordinate system O. Which of the following is correct? (1) B A R or (2) B R A By doing some simple worked examples, it seems that (1) is correct. However, my intuition says that (2) is correct, because the transformation to A should be applied before the transformation to B, via R. Which is it? Thanks )


Including sprite file for mobile games I'm making a simple online RPG for Android amp IOS using HTML5 amp Phonegap and was wondering should I include sprite file with the game for downloads (because of bandwidth)? What should I do when I modify the sprite file in the future? (i.e. forced update).


How do I fix this unintentional chromatic aberration on a lightmap? Some strange rainbow halos (front and left) appear after computation of a lightmap for direct light. The formula is dot dot2 ( dist dist ) dl gt intensity with gamma correction, lightmap is computed as vec3 t and ultimately cropped to 3 bytes. However, brightness of the region in question fit into 255 nicely, and even calculating in byte instead of float beforehand result in just a subtle quot oil painting quot effect and does not produce such artifact across entire image. My best guess is how this artifact appear from base change in a floating point math, but I don't know for sure nor do I understand what exactly is happening.


What does the term 'photorealistic' really mean? I was wondering about the term 'photorealistic' in regards to rendering and was wondering how this is used. Is it used to describe a shader (or set of) that have certain quantifiable features? Or any rendering thats not meant to be abstract, like the cartoon effect seen in Borderlands? Or is it just a subjective term meaning 'really really realistic'?


How can I include vertex color information in .OBJ files? The .obj files I export are missing data for vertex colors. Is there a way to include color information in the .obj file? If not, what are the alternatives?


Correctly bitmasking path tiles based on existing paths Currently, I have a bitmasking implementation that sometimes incorrectly bitmasks the tiles. Conventionally, it is done correctly, and the math etc is sound, but it achieves results such as the following This is similar to what you might expect, and looks fine when doing simple x shaped crossings. However, I would like for the images to remain unchanged in some of these cases. For instance, the parallel paths in the third image would remain parallel paths instead of being bitmasked into many crossings. In the first and second images, only the parts of the path highlighted in the following images would be bitmasked (Different parts of path labelled for clarity.) If I purely update only the tiles that make up the newest path, I again get good results in simple x shaped crossings, however I get results such as those demonstrated in the following image What could I do to achieve results where this would not occur? I have though about adding some sort of flag to the tile to indicate that it is a crossing, but how could I detect that?


Precomputing Visibility Having noticed that UDK (Unreal) and Unity 3 include similar pre computed visibility solutions that unlike Quake are not dependent on level geometry, I've been trying to figure out how the calculation is done. The original Quake system is well documented You divide the world into convex volumes that limit both the camera and the geometry. Each volume has a list of all the other volumes that are visible from it. Visibility would be computed by firing rays at some random distribution of points in the target volume and see if any hit. And because the position of the camera in the source volume could have an effect, those thousands of rays would have to be fired from multiple places in the source cell. So what I'm wondering is if there's any been fundamental change to this basic scheme in the intervening 15 or so years? I can see how to adapt it to a UDK Unity scheme that has regular source volumes and deals mostly with arbitrary meshes as the targets, but is there a better way than stochastic ray testing?


How do games deal with Z sorting partially transparent foliage textures? I was busy implementing basic transparency in a prototype I'm working on when something occurred to me. In order for a given texture's transparency to work as expected, the (semi )transparent texture must be drawn after whatever is behind it, right? Well, if we take for example a tree or shrub in a game like Skyrim, the texture(s) that make up the foliage on that tree or shrub must include some transparency somewhere, right? A vertex perfect leaf model would be far too resource intensive. But the player can move around, and sometimes through, any plant at will, thus changing the relative position of all textures to the camera. Doesn't this mean that the game has to constantly Z sort all textures, both between models and even within a single plant model, whenever the player moves (so potentially every single frame)? Isn't that very resource intensive? How do games with lots of partially transparent textures deal with this?


How to generate a star onto a render texture with spherical warping How would one proceduraly generate a star in a compute shader that looks like one of thes two at any size needed. Also any way transfer this into a spherical map, would be appreciated. Goal is to create a spherical skybox of stars, (stars a pre generated, and not just decoration). Also I have searched about everywhere for such equations, and or tutorials but have not found anything so far. So far got accurate positioning of the stars on the spherical skybox but lack the equations to get it looking like I want. Preferably the one on the right. This below is what I currently have, 5 to 15ms processing time, little over 30k stars Using Unity2019.3.1f1, needs to be compute shader compatible. (if not I will convert it somehow) Render Texture output.


Why is Y up in many Games? I learned at school that the z axis is up. It is the same in modeling software like Blender. However in many games the y axis is up. What is the reason?


Why does clipping take place after illumination? Can you explain why clipping takes place after the illumination process in the rendering pipeline? Would it be not cheaper to clip first and do then the illumination?


How do I generate a random curve for landscape (like Worms)? Possible Duplicate How do I generate terrain like that of Scorched Earth? How can I generate Worms style terrain? I must build random curve line for the 2D Game on the BitMap (like in Worms, from the side). Teacher said that I should do it using Terrain Generation through recourcy (I work in Delphi 7). I understand the main principle, but I don't know how to introduce it as code. All measurements according to the screen resolution.


Why do games ask for screen resolution instead of automatically fitting the window size? It seems to me that it would be more logical, reusable and user friendly to implement flexible, responsive UI layout over a 3d or 2d screen, which can then be run on any screen resolution. Some modern games auto detect screen resolution and adjust the game to that, but the option to change the resolution still remains in the settings. Why is this option there? My guess is that this is one way to provide older machines with a way to improve performance by rendering less graphics and just stretching them across the screen, but surely there are better ways of improving performance (choosing different texture and model qualities, for example).


How does code translate to graphics? I know this is kind of a basic question, but I'm trying to create my own game from scratch and really don't understand this. How does the code of a videogame program certain pixels to be certain colors and then move them in agreement with the player's movement? For example, in a 2D platformer, how does the code program the on screen visuals of the world that the player is in? And then, how does it move a certain object matching the speed of the player and then eventually have it go off screen? Thanks in advance!!


Fastest way to create a simple particle effect I am looking to the fastest way to create really simple particle effect that will be spammed like hell on the game... Basically, my game looks like a vectrex game, made mostly of lines... I want to make some small explosions that will be really common. There are something faster than just moving around some points and rendering with GL Point?


SDL2 linux fullscreen issue at lower than desktop resolution Having a problem trying to get proper fullscreen in linux. I'm using 1440x900 on desktop. When i set SDL to use 1280x720 as fullscreen, it does change screen resolution. But if i drag the mouse cursor to the bottom or right edge of the game screen, it "scrolls" the screen beyond the game surface and makes part of the desktop visible. Here's how I set the window screen gameWindow SDL CreateWindow( "SDL Tutorial", SDL WINDOWPOS CENTERED, SDL WINDOWPOS CENTERED, screenWidth, screenHeight, SDL WINDOW FULLSCREEN SDL WINDOW BORDERLESS ) Am i missing some flag(s) perhaps? Is this a common problem? I'm on Linux Mint MATE (Rosa). This problem also occurs when trying to run the same build in an Openbox session. Using nVidia drivers (x64, v340.96) from nvidia.com, on 9600 GT card(s). No twin dual screen or second Workspaces. Any good tips on how to avoid or workaround this issue?


What is the purpose of the stencil buffer ? More precisely, what is a stencil in computer graphics? I read the stencil word a lot, and I don't have a clue what is its real purpose in computer graphics. Seeing the picture in black and white on wikipedia, I'm still having problem with it. Why do we use a stencil or a stencil buffer, and what is the difference with a Z buffer ? Why using this word which seems to have some meaning in graphic design ?


What do you use to create sprite graphics? Possible Duplicate What tools do you use for 2D art sprite creation? What do you folks suggest for creating sprite graphics and sprite sheets? I fiddle with pixelformer and tilestudio. Pixelfromer has a kicken interface, it is quick and easy to make graphics, but a bit cumbersom if you want to make a spritemap. Tile Studio is a interesting mix or tiles and maps, but it is a bit buggy and basic. The Adobe series, just don't really seem to handle tiny graphics well. (there is a previous posting of this question existing, but it is a year old and I was hoping for further updated input from the community)


What are some good books which detail the fundamentals of graphics processing? The best book on the nitty gritty of graphics that I've found is Computer Graphics Principles and Practice http www.amazon.com Computer Graphics Principles James Foley dp 0201121107 However, as this was written in the early 90s, it is a little out of date. Are there some similar books which go over the more recent developments?


Opengl in 500 lines barycentric calculation question https github.com ssloy tinyrenderer wiki Lesson 2 Triangle rasterization and back face culling I cannot figure out how we go from uAB vector vAC vector PA vector 0 to the linear system with those subscripts x and y? Is there another way of explaining how we take three vectors, split them into x and y type vectors, and produce a cross product that can be used to find the barycentric coords (u, v, w)? Also, I am not sure why there is a division by the z component of the cross product in last line of the barycentric function. Maybe the answer to my first question will make this more obvious. Below is a picture of the section of the tutorial where I am stuck. Link to full page is above.


How do I load chunks of data from an assest manager during a loading screen? I'm developing an Android game. Basically I want to pre load all graphics sounds when the app is first loaded. But I also would like to show a progress bar as this is happening. Here is a snippet of Java Android code to display a progress bar while doing some work public class LoadingScreen extends Activity private static int progress 0 private ProgressBar progressBar private int progressStatus 0 private Handler handler new Handler() Called when the activity is first created. Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState) setContentView(R.layout.loadingscreen) progressBar (ProgressBar) findViewById(R.id.progress) do some work in background thread new Thread(new Runnable() public void run() while (progressStatus lt 100) progressStatus doSomeWork() Update the progress bar handler.post(new Runnable() public void run() progressBar.setProgress(progressStatus) ) hides the progress bar handler.post(new Runnable() public void run() progressBar.setVisibility(8) ) private int doSomeWork() try simulate doing some work Thread.sleep(50) catch (InterruptedException e) return progress ).start() My question is how do I design my Asset Manager to load "chunks" of data (bitmaps and sounds music) in the doSomeWork() function? Would it be some sort of stack that I keep popping off the next asset to load? How do I determine how much of the progress bar I should increment after loading a "chunk" of data? Is there a better way to approach this or is this the correct way?


Why are huge polygon amounts bad? It is always said that the polygon amount of a single modell must be as little as possible when it comes to realtime simulations such as computer games. (Or at least lower than when rendering a movie) I am fully aware that this must be done in order to save performance. But aside from that information i cannot find why huge polygon amounts must be avoided. (In Short I know that polygons eat performance. I want to know why they eat performance) So my question would be What happens when a frame is rendered? The polygons are surely somehow processed in the graphicard. What happens there?. If possible i would like to have some links to sites containig this information.


What is the purpose for multiple windows in games? A lot of game development APIs recently got support for multiple windows (such as SDL 2, and GLFW 3). But why did they add that feature? I've never seen a game in my life use multiple windows (with the exceptions of a launcher, or a messagebox). Is there something I'm missing here? Is there an actual game development purpose to it? I'm very confused of why they did that.


How to create the "drunk camera" effect in GTA 4? If you have played GTA 4, then you have probably been drunk at some stage. This is one of the best intoxicated simulators I have ever seen. It is actually hard or sometimes almost impossible to drive a vehicle while drunk in this game. I know that a lot of the things that make up this drunk experience are changes to the controls or having random changes in direction, but how would the camera be done? The camera seems to wave in and out and side to side. It also has changing blur, and other effects going on. Would this be some kind of shader? What are the effects that are used on top of each other to create the experience?


How do mobile mmo's deal with the graphical resources? I'm am creating an MMO(probably won't be so massive), and was wondering how to deal with the graphical resources. Obviously, I can't have what could be possibly a few gigs of images and animations loaded up to the client, so I need another way of doing it. I have tried having a php webserver that updates itself and writes to a file that the client draws, however this seems slow. How can I speed up the process of updating the graphics while not having too much into the client?


Which image format is more memory efficient PNG, JPEG, or GIF? Which image format is more efficient to save memory? PNG, JPEG, or GIF?


Generating Normal map from a Image with a given Albedo map I am working on a research problem part of which involves generating normal map from a given image of a rusted object. I searched the internet for techniques to achieve the above and apparently crazybump is mentioned a lot. I tried it but it didn't produce the desirable effects. Also I am looking for a method which draws inspiration from an existing research paper not some closed source software. I turned my attention to the technique described in the this paper. Results from this technique are satisfactory for normal objects because of bias in the training data but it doesn't work very well in the case of rusted objects. After this I focussed my attention on generating Albedo map (the above problem would become more solvable if Albedo map is obtained). Fortunately I am able to generate pretty good albedo maps for images of rusted objects. I used this paper's approach to generate Albedo maps. Now I want to know a good technique to get Normal map given an image and it's corresponding Albedo map. To give you an idea of what kind of images I am working with I am attaching a sample. Links to research material would be really appreciated. Thanks!


Stopping Animations For Player In Java Using Slick2D I have a problem with stopping animations for a player in Slick2D. I have tried many solutions to the problem and have looked up a couple of resources but I am still stumped by the fact that it is not working. Here's the code I have for my class public SpriteSheet playerSS null protected InputHandler inputHandler public float playerX, playerY 250f private Animation sprite, runningAnimationLEFT, runningAnimationRIGHT, runningAnimationUP, runningAnimationDOWN private int duration 200 public Game (int stateID) Override public int getID() return Main.game GAMESTATE 1 Override public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException playerSS new SpriteSheet("res player sprite sheet.png", 50, 75) ANIMATIONS runningAnimationDOWN new Animation() runningAnimationDOWN.setAutoUpdate(true) runningAnimationDOWN.addFrame(playerSS.getSprite(1, 0), duration) runningAnimationDOWN.addFrame(playerSS.getSprite(0, 0), duration) runningAnimationDOWN.addFrame(playerSS.getSprite(2, 0), duration) runningAnimationLEFT new Animation() runningAnimationLEFT.setAutoUpdate(true) runningAnimationLEFT.addFrame(playerSS.getSprite(1, 1), duration) runningAnimationLEFT.addFrame(playerSS.getSprite(0, 1), duration) runningAnimationLEFT.addFrame(playerSS.getSprite(2, 1), duration) runningAnimationRIGHT new Animation() runningAnimationRIGHT.setAutoUpdate(true) runningAnimationRIGHT.addFrame(playerSS.getSprite(1, 2), duration) runningAnimationRIGHT.addFrame(playerSS.getSprite(0, 2), duration) runningAnimationRIGHT.addFrame(playerSS.getSprite(2, 2), duration) runningAnimationUP new Animation() runningAnimationUP.setAutoUpdate(true) runningAnimationUP.addFrame(playerSS.getSprite(1, 3), duration) runningAnimationUP.addFrame(playerSS.getSprite(0, 3), duration) runningAnimationUP.addFrame(playerSS.getSprite(2, 3), duration) sprite runningAnimationDOWN Override public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) throws SlickException inputHandler.updateKeyboardRelay(gameContainer) if (inputHandler.keyUP) sprite runningAnimationUP sprite.update(delta) playerY delta 0.1f else Stopping Animation goes here. if (inputHandler.keyDOWN) sprite runningAnimationDOWN sprite.update(delta) playerY delta 0.1f else Stopping Animation goes here. if (inputHandler.keyLEFT) sprite runningAnimationLEFT sprite.update(delta) playerX delta 0.1f else Stopping Animation goes here. if (inputHandler.keyRIGHT) sprite runningAnimationRIGHT sprite.update(delta) playerX delta 0.1f else Stopping Animation goes here. Override public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException sprite.draw(playerX, playerY) How would I go about stopping the animation from playing over and over again once the movement key is lifted? i.e. If someone presses the 'W' key the player does an animation going upwards, but if the user stops using the 'W' key how would I make it so that the animation stops playing as well?


boolean operations on meshes given a set of vertices and triangles for each mesh. Does anyone know of an algorithm, or a place to start looking( I tried google first but haven't found a good place to get started) to perform boolean operations on said meshes and get a set of vertices and triangle for the resulting mesh? Of particular interest are subtraction and union. Example pictures http www.rhino3d.com 4 help Commands Booleans.htm


What is a lobe, in reference to lighting and graphics I sometimes see references to lobes when talking about lighting, especially with specular lighting, but also with spherical harmonics which doesn't do specular. Can anyone explain what exactly a lobe is?


Web site for XAML snippet sharing? I am making a game with WPF and C , and I frequently am in need of artwork for it. Some things could be easily shared, such as explosion animations, exhaust plumes, etc. I was wondering if there are any good web sites for this? All I can find are tutorials and the infrequent sample, but I imagine there is a site out there that I am missing. I would also like to clarify that I am looking for pure vector based XAML snippets. I know there are a lot of sites out there for sprites and textures, but I am looking for XAML components that I can tweak.


What's the difference between using hardware accelerated APIs and the OS's drawing API? On Windows, I can do drawing with the OS API without OpenGL or D3D. The code I am writing will make calls to a device driver and tell the GPU what to do regardless, right? How is using OpenGL different exactly? Do these libraries have code that will interact with the GPU differently than just the Windows API does?


Aquaria like graphics look in 3DS Max? I'm making a 2D game and I'm starting to think about graphics. I'm pretty good at 3D modelling, but I'm not very good at drawing or painting. I was wondering if there were settings, or even a renderer that someone could recommend that could achieve the nice painted look found in Aquaria. Thanks.


Ground contact point for animated character sprites in an isometric game? I'm working on an isometric game. I have the 3D pre rendered sprites for directions per state (walking running, etc.) per frame. Now I need to know where a particular character stands on the ground to have it synchronized. But this "ground contact point" (GCP) changes from frame to frame, and is basically (slightly) different for every combination. At this moment I have some rough average, but sprite wiggles a bit during animation. It's rendered correctly (1024x768), but cropping of the frames even though it correctly removes empty borders, it also removes the "offset" information, which is no longer there. So I basically need to remove empty borders while taking into account all the frames in all the animations. So the character in the sprite animation is still stabilized, but unneeded space is removed. Example ensp ensp ensp ensp Is there any software that does it, or is there some technique to do it?


How come the 3d graphics and animations of MMORPGs are usually worse than non online 3d games? I have noticed that in general it seems like the 3d graphics and animations for MMOs and MMORPGs seem not as seductive and polished as the graphics for normal, non online 3d games. How come this is the case? or Is my judgement inaccurate? If my judgement is inaccurate please provide examples of MMORPGs that render 3d graphics and animations that are superior to normal, non online 3d games.


Where can I find articles books on 2D graphics (how it works etc.)? After I have been through more intensive C studies, I am thinking of giving it a start in my practices of computer game programming. Therefore, I think 2D knowledge (processing images, animating frames, etc.) would be a good place to start. However, I don't seem to find many articles on 2D (mostly 3D), and if found one, it is mostly stuffs like how to use a 2D game engine. I would really want something much more low level, or "from scratch" ideas. I want articles books that would answer something like How would I import images into C ? (Let's say, if I want to import jpeg bmp etc. file into raw C code, what would I do?) Basically, I just want to have enough low level knowledge about computer graphics to be able to create something like 2D game engine from scratch.


Which tools are artists using out there and how for game development to produce the material used by game programmers? What processes, tools, methods are used by game artists to prepare materials for the programmers? I am interested in tools (ie photoshop, pixelmator, etc for drawing) and also how they are used together to produce texture atlases or individual images for the programmers. Methods or way of working (tool chains maybe), which can be used by the artist to Present ideas (sketches) Mesh up game images (photosop front menu, in game) Cut up images layers into (ie copy paste?) smaller individual pieces texture atlases (some other tool) Generate coordinates ie (xywh) for button "Options" on the main screen which is stored as main options.png or (uvhw, xywh) for in game HUD which is in a texture atlas.png. Any way to automate some of the steps above? before edit The artist(s) might use hand drawings scanner sketch pad for illustration. These are then imported and further improved in some other image manipulation tools. The result then can be used to produce both preview of the game (menu, in game meshups) and final elements which will be used by the programmer(s) individual images or texture atlases. Which tools are artists using out there and how for game development to produce the material used by game programmers? I am particularly interested if there are automated tools where a small change at the illustration part can be propagated to produce final production images textures without the need for the artist to cut merge them.


High Performance Vector Graphics Solutions I'm looking for a high performance vector graphics library I can use in my games. I'm thinking along the lines of vector graphics such as those that can be made with SVG. I'll consider any language at the moment (but must run on Windows). A solution that takes advantage of GPU hardware would be great. Thanks in advance.


How to do this sprite motion blur? Some of you may know fraxy... Basically, I was watching this video http www.youtube.com watch?v uL7zWdDCtOE And there are some times where some sprites spin really fast (4 00 mark for example), and I cannot figure how the motion blur effect was done. I looked in the game folder, and found the sprite, it certainly does not has the blur added to it (in fact, it is even a .bmp! Not a PNG or anything that supporta alpha natively), and the engine IF using OpenGL, may not be clear (the resolution is fairly low too), also nothing else is getting blurred (so the effect is localized to some sprites... if you pay attention there are other moving objects that get blurry too). So, how they do this glowing blur? EDIT On the video I am talking about the two things "spinning" in the left and right edge of the screen, they are shooting, and the sprite of their bullets are the same as their own sprite, but if you pay attention as they spin their sprites leave a trail, actually if you put the video some seconds before, you will see with the screen more empty, and the effect can be seen clearly. EDIT2 I don't think Fraxy use shaders, and I am sure it does not use OpenGL either (since it run on computers that don't run OpenGL games). I know it is easy to do with shaders, with per pixel calculations, I am asking how to do WITHOUT them.


What is a good alternative to Unified Shader for Shadows? Most shadow systems I have seen use a unified shader system for shadowing techniques, resulting in an uber shader for the projects. What alternatives do you find work well or is the unified shader the best approach?


How do I make a progress bar with letters that get "filled in"? I want to make a progress bar made of text! I have two images One with the text in gray, the other coloured As my game is loading, I want the letters to "fill up" with color They would start out gray, then fill in. I was thinking of overlaying a transparent rectangle over the gray image, then stretching the transparent rectangle to match the progress. But then the background will be coloured too. I want only the letters to be coloured! How can I do this?


What is the Xbox360's D3DRS VIEWPORTENABLE equivalent on WinXP D3D9? I posted this on StackOverlow, but of course it should be posted here. I am maintaining a multiplatform codebase for Xbox360 and WinXP. I am seeing an issue on the XP side that appears to be related to D3DRS VIEWPORTENABLE on the Xbox360 version not having an equivalent on WinXP D3D9. This article had an interesting idea, but the only way to construct an identity matrix is to supply negative numbers to D3DVIEWPORT9 X and D3DVIEWPORT9 Height, but they are unsigned numbers. (I tried to put in negative numbers anyway, but nothing interesting happened.) So, how does one emulate the behavior of D3DRS VIEWPORTENABLE under WinXP D3D9? (For clarity, the result I'm seeing is that a 2d screen aligned quad works fine on Xbox360 but is offset stretched on WinXP. In fact, the (0, 0) starts in the center of the screen on WinXP instead of in the lower left corner like on the Xbox360 as a result of applying the viewport transform.) Update I didn't have an Xbox360 devkit at the time I wrote up this question, but I've since gotten one. I commented out the disabling of the D3DRS VIEWPORTENABLE state, and the exact same behavior resulted on the Xbox360 as on the WinXP build. So, there must be some DirectX magic to bridge the gap here for emulating D3DRS VIEWPORTENABLE being turned off on WinXP.


How to emulate Mode 13h in a modern 3D renderer? I was indulging in nostalgia and remembered the first game I created, which used Mode 13h. This mode was really simple to work with, since it was essentially just an array of bytes with an element for each pixel on the screen (using an indexed color scheme). So I thought it might be fun to create something nowadays under these restrictions, but on modern hardware. The API could be as simple as public class Mode13h public byte VideoMemory new byte 320 200 public Color Palette new Color 256 Now I'm wondering what would be the best way to get this data on the screen, using something like XNA DirectX OpenGL. The only solution I could think of was to create a texture with the same size as the VideoMemory array, write the contents of VideoMemory to it every frame, then render that texture in a full screen quad with the correct aspect ratio and using point texture filtering for that retro look. Is there a better way?


Making Edges of Hand Drawn Tileset Match Up I'm making a tile based platformer. A friend at college is doing all my art, and so far it's beautifully hand drawn. The problem is, I can't seem to make the edges of the tilesets match up. He measures them meticulously to get sections to match up, but, due to variations in his art medium, tiles that aren't next to each other in his drawing don't match up. For example, he's drawn a basic 9 slice tileset, and the top to center, left top to left center, right top to right center, etc. all connect perfectly because they're touching each other in his drawing. But when I clip the tiles apart and put them together in other variations or try to put other "change up" tiles together (any tile that wasn't touching in his drawing), the larger features fit together because of his measurements, but you can see an obvious seam where they join. I've been using the heal tool in my graphic editor to fix the seams and re export the tiles with edited edges to fit together correctly, and it works well, but when I heal the edges for one seam, it makes another seam appear. Note I don't want a solution to fix the seams at runtime using graphical filter magic or something on the code side. I'm looking for a solution to process the images and export them so that they fit together. EDIT Here's one of the tiles for reference. It tiles along the bottom of a block of stone. And here's a 9 slice thumbnail of an early stage of the tileset Edit again To be clear, it's not the big ish things (stone sides, grass, etc.) connecting that's my problem. My artist already measures everything to make it match up. It's the variations in shading and impreciseness of the physical medium that's the problem.


How to generate a star onto a render texture with spherical warping How would one proceduraly generate a star in a compute shader that looks like one of thes two at any size needed. Also any way transfer this into a spherical map, would be appreciated. Goal is to create a spherical skybox of stars, (stars a pre generated, and not just decoration). Also I have searched about everywhere for such equations, and or tutorials but have not found anything so far. So far got accurate positioning of the stars on the spherical skybox but lack the equations to get it looking like I want. Preferably the one on the right. This below is what I currently have, 5 to 15ms processing time, little over 30k stars Using Unity2019.3.1f1, needs to be compute shader compatible. (if not I will convert it somehow) Render Texture output.


How can I animate a recursive algorithm? Say I have a recursive algorithm, for example one that generates a random tree Pseudocode, just a simple algorithm it isn't perfect. function generate branch(angle, length, current depth, max depth) var branch Branch(angle, length) creates a new branch if (current depth max depth) return branch current depth random int(min, max) branch.subbranches generate branch(random int(0, angle random int( 30, 30)), random int(0, 20) current depth, max depth) recursion return branch var trunk generate branch(0, random int(10), 0, 5) RenderTree(trunk) The problem is that this will render the entire tree in one frame. If I want to animate this (i.e. grow the tree over time), how would I do that? What is the best way to do this? The game uses a game loop.


How do I replicate the warp effect from Geometry Wars? I'm trying to achieve the warp effect that you see in games like Geometry Wars. Can someone help explain what is going on here? I feel like the grid's z axis is manipulated in some way, any way, by the programmer, but is there maybe some known mathematical equation to really get the correct warping effect? Edit To be more specific, I mean the warping of the grid. How everything looks pulled towards the negative z axis and then bounces.


Cheap way to soften contactpoint of character with ground The view of my game is always semi topdown. I'm trying to make the contactpoint between characters and the floorplane more grounded without rendering hundreds of sprites. One thing that I think could work well is to just hide some pixels of every object that is i.e. 2 cms above the floor. See GIF below of an example I did in Photoshop Things that I'm thinking about check the z depth before rendering if it's very close, then randomly don't render the pixel randomly writing "wrong" depth buffer values for the ground plane a small layer 2cm over the groundplane that writes z values only draw this before the character As I'm still in the research phase, I'd like to also explore other possibilities. Is there already a well established way to do this?


Precomputing Visibility Having noticed that UDK (Unreal) and Unity 3 include similar pre computed visibility solutions that unlike Quake are not dependent on level geometry, I've been trying to figure out how the calculation is done. The original Quake system is well documented You divide the world into convex volumes that limit both the camera and the geometry. Each volume has a list of all the other volumes that are visible from it. Visibility would be computed by firing rays at some random distribution of points in the target volume and see if any hit. And because the position of the camera in the source volume could have an effect, those thousands of rays would have to be fired from multiple places in the source cell. So what I'm wondering is if there's any been fundamental change to this basic scheme in the intervening 15 or so years? I can see how to adapt it to a UDK Unity scheme that has regular source volumes and deals mostly with arbitrary meshes as the targets, but is there a better way than stochastic ray testing?


Find point along x axis where yz plane flips to back facing after perspective projection. Have a solution but don't know why it works I am trying to find the point along the x axis where a plane with normal pointing along the x axis would flip to back facing after perspective projection. Essentially the red line in this image. My first attempt to find it I just sampled along the x axis checking if a triangle there was back facing after projection. This only gave me an approximation but I could make the approximation as accurate as I wanted by just sampling more planes so I used this as a baseline to verify other solutions. I then tried the following vec4 center projection.inverse() vec4(0,0,0,1) center center.w float d dot(center.xyz, vec3(1,0,0)) vec3 point vec3(1,0,0) d But this did not work, it was close but not right. See this image, the red line is the sampled point and the blue is the one calculated from that. I then tried changing the calculation for center to projection.inverse() vec4(0,0, 1,1) to see what that would look like. With the the sampled point in red, the blue line being the previous version and the green the new version. I got the following image which as you can see is still not correct. But I noticed that the green was always directly between the blue and the red so I tried the following. vec4 c1 projection.inverse() vec4(0,0,0,1) c1 c1.w float d1 dot(c1.xyz, vec3(1,0,0)) vec4 c2 projection.inverse() vec4(0,0, 1,1) c2 c2.w float d2 dot(c2.xyz, vec3(1,0,0)) float d (d2 d1) 2 d1 vec3 point vec3(1,0,0) d Which seems to be correct but I have no idea why that works. It is always extremely close to the sampled point so I assume it is correct. My question is why does this work?


How can I improve or replace my programmer art? Say I'm a programmer who has done his own sprites or 3d models which would fall into programmer ish kind of art. What steps can I take in order to improve or replace my own art?


How do you ensure consistent experience across multiple graphics cards (or even driver versions)? So I was writing a simple 2D game with OpenGL and SDL and had this problem when there was awful tearing when running in windowed mode (even though I explicitly asked SDL SetVideoMode to use double buffering). Didn't worry about it all too much because most of the time the game grabs the entire screen, windowed mode is just for debugging. Anyway, yesterday I updated my nVidia drivers and tearing disappeared, the game runs smooth and looks nice in windowed mode too. I can see how the problem may be in the graphics driver, but this leads to a question. Obviously, professional game developers have to deal with a lot of different hardware software configurations. What are the techniques they use to make sure the game looks the roughly the same on different graphics cards or even the same model of graphics card, but with different driver versions?


Draw multiple LINE LOOPs in one glDrawElements call The game I'm working on has OpenGL (2.1) vector graphics, and I need to draw up to 1000 enemies, each of which is composed of between 4 and 100 lines. Each enemy can be drawn as a single line loop, so one strategy for drawing would be to call glDrawElements(GL LINE LOOP, ...) once for each enemy. This results in too many (up to 1000) calls of glDrawElements per frame. Another strategy would be to separate the line loops that form each enemy into individual line segments, and call glDrawElements(GL LINES, ...). This results in a lot of repeated vertices though, which I would like to avoid. Is there a way to draw multiple line loops in a single call to glDrawElements (or with some other function)? I guess I would need some indicator in the vertex element array to mark where each line loop ended.


Graphics messed up when I try to reskin the game in Android Studio I need a little help. I'm new in Android Studio, I have a game where I want to reskin the design. First of all when I install it on my phone with the original files the game run perfectly without problems. When I try to reskin the photos in my assets folder, I save it, build it in APK file, I install the game and then the graphics is messed up. Here is screenshot of the game after the reskin. Sorry for my bad English...


How do I get started making Android games? I am new to game development. I am interested in developing 2D games for the Android platform. What is the best place to start with (i.e) What are the basics and how to proceed? I already have programming experience in Java but don't have any experience with graphics or animation.


Attach simple, portable 2D graphics for a c game I have a game written in C (using STL and c 11 extensively). I would like to do the following things Attach graphics to this game Think chessboard of some kind. I just need some pictures and simple status bars, no movement necessary, even though it would be nice I guess. It's a turn based game. Port the game across Windows Android iOS So, all in all, I need a tool that would provide a portable, simple, 2D graphical interface. A tool that would allow me to "bind" my c code to portable graphical representation. How would I go about making this idea come true?


Auto tiling with Yoshi's Island style tiles I'm creating a 2D platformer and I'd like to implement an auto tiling system. Normally, this wouldn't be particularly difficult. However, I'd like to have tiles like in Yoshi's Island, where the graphics extend past the actual collidable tile's boundaries. Consider this image Although the eggs and the Piranha Plant are clearly resting on the ground, the flower tiles continue behind them, out of the collidable tile. I know that it would be simple to do by hand, but extremely time consuming. Using an auto tiling algorithm would save me a lot of time and boredom, but I'm not sure where to start.


Outsourcing Artwork Hourly or Per Project? I've hired people to produce art and graphics before, but only ever at a per job rate and that has worked out well. This question is for both artists and the people who hire them As a buyer, are there any situations or types of projects you've experienced where it worked out better billed at an hourly rate? For artists, do you have a preference for one over the other and if so, why?


top down game checking, drawing enemy's line of sight area with obstacles Examples of what i'm going to need I'm using cocos2d to draw a CCTMXTiledMap, on those tiles i'll have to draw the LOS cone. How would i test if the player is within that cone, taking obstacles into account? How would i draw the line of sight area on the map tiles, again taking obstacles into account, like in the examples above? This is a re post of a question i've put on stackoverflow.


What are the differences between EGA and VGA for MSDOS API? How different is the API for EGA and VGA for MSDOS applications? We're talking about the API that was used in games like Doom, Quest for Glory, Duke 3D, etc. More specifically, how much work would be involved in changing an application's use of EGA APIs to VGA APIs? or SVGA even? They seem to be fairly similar in terms of interrupt strategies, registers used, etc. Looking for a little more definite answer though, if possible. Forum post that suggests wrapping memory access may provide a partial solution http www.allegro.cc forums thread 604334 Some basic information on using VGA, but nothing on EGA http www.brackeen.com vga basics.html http www.wagemakers.be english doc vga


How do I load chunks of data from an assest manager during a loading screen? I'm developing an Android game. Basically I want to pre load all graphics sounds when the app is first loaded. But I also would like to show a progress bar as this is happening. Here is a snippet of Java Android code to display a progress bar while doing some work public class LoadingScreen extends Activity private static int progress 0 private ProgressBar progressBar private int progressStatus 0 private Handler handler new Handler() Called when the activity is first created. Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState) setContentView(R.layout.loadingscreen) progressBar (ProgressBar) findViewById(R.id.progress) do some work in background thread new Thread(new Runnable() public void run() while (progressStatus lt 100) progressStatus doSomeWork() Update the progress bar handler.post(new Runnable() public void run() progressBar.setProgress(progressStatus) ) hides the progress bar handler.post(new Runnable() public void run() progressBar.setVisibility(8) ) private int doSomeWork() try simulate doing some work Thread.sleep(50) catch (InterruptedException e) return progress ).start() My question is how do I design my Asset Manager to load "chunks" of data (bitmaps and sounds music) in the doSomeWork() function? Would it be some sort of stack that I keep popping off the next asset to load? How do I determine how much of the progress bar I should increment after loading a "chunk" of data? Is there a better way to approach this or is this the correct way?


How to make a Sprite using CoreGraphics iOS Cocos2d iPhone I'm trying to make a sprite that uses the graphics that are made with core graphics. I cant seem to find anything to explain how to make shapes using core graphics to create a sprite to use in cocos2d iPhone. Thanks for any insights and help!


How could one go about segmented sprite animation in Unity? I've been exploring ways of designing characters and I'm interested in this technique. It's used in many retro games, mostly for bosses, like in Gunstar Heroes(Seven Force, that one Block guy from level 1), Castlevania(Talos) and Mischief Makers. It's used for the player character in the case of Yoshi's Story, Paper Mario and more recently Hardcore Mecha. Currently I'm aware of the Anima 2D system in Unity, however this is more directly mimicking 3d model functionality by warping the meshes as well, and doesn't seem to support spritesheets per limb. I'm thinking of using individual quads per limb with their own spritesheets, would it be difficult to code my own sort of skeleton system? For anyone still curious confused to what im referring to, This technique was used fairly often in Castlevania games or games by the company Treasure.


What does the term "channel" mean when used in regards to computer graphics? I was studying terminology for computer graphics, and this statement came up that confused me. The image can have alpha channels for transparency. I tried searching for the meaning of the term "alpha channel," but I got really confused by the definition which used another concept called a "channel." I'm not really sure what this means, so could someone be kind enough to please explain this term to me?


Web site for XAML snippet sharing? I am making a game with WPF and C , and I frequently am in need of artwork for it. Some things could be easily shared, such as explosion animations, exhaust plumes, etc. I was wondering if there are any good web sites for this? All I can find are tutorials and the infrequent sample, but I imagine there is a site out there that I am missing. I would also like to clarify that I am looking for pure vector based XAML snippets. I know there are a lot of sites out there for sprites and textures, but I am looking for XAML components that I can tweak.


how to improve sprite animations to reduce FPS My game has different, and detailed animations throughout the game. For example, the main character has an idle stance, so its not just painted still, giving him some life. Death animation, hurt animation, etc... even the background scenario has animations(which I don't think I went with the best approach here, but, it's working for now, this will be in another thread if not answered here) Anyways, the thing is, while the main character had these animations only that character was in the game at that time, so everything ran smoothly. After adding another character, the enemy, the burden of animations seems to overcharge the FPS and just slows the game down. The most obvious of this problems was that the spritesheet I was using was 1 per character, I figured how to use spritebatchnode efficiently and now 1 spritebatchnode covers the 2 characters animation set. The FPS tried to get back to normal, but its still laggy at times. This worries me because my game design has more enemies to the game, meaning that it will have this issue in a bigger scale. So I believe that its because of my animation approach, its poor, and inefficient making my game run slow. I have been trying to find the answer online with no luck, and I don't my approach is the best. I tried working some solutions by my own, but they end up in the same thing. THE ONLY, the only way I find how to reduce this problem is to make my sprites smaller, its not a big deal, but I wouldn't like this solution.


Why does the Texture placement of my CCSprite slightly shift when changing it's location? So I've been seeing this issue for a while now. When using a delta method to change the location of a CCSprite, the placement of texture of my sprite slightly moves into the direction where I'm headed, while the physicsbody stays the same. This is really noticeable, since I'm using CCActionFollow to center this sprite in the view at all times. The code is displayed below. Is this normal behaviour, or am I perhaps overlooking something really obvious? Thanks! (void) move (CCTime)delta toPosition (CGPoint)point OverworldScene parentScene (OverworldScene )self.parent.parent.parent Go over physics node OverworldLayer parentLayer (OverworldLayer )self.parent.parent Go over physics node meewind of tegenwind? float angleWind parentScene.compass.rotation float angleShip self.rotation float difference float windFactor if (angleWind gt angleShip) difference angleWind angleShip else difference angleShip angleWind if (difference gt 180) difference 360 difference Incorporate wind power... if (difference gt 90) Tegenwind windFactor 1 ((((90 (180 difference)) 90)) (parentLayer.windPower 12)) else Meewind windFactor 1 ((((90 difference) 90)) (parentLayer.windPower 12)) if (windFactor lt 0.4) windFactor 0.4 point is the current position of the user's sprite a, b and c are the right triangle sides lengths formed by the caser sprite and the user's sprite positions float a ABS(self.position.y point.y) float b ABS(self.position.x point.x) float c sqrt(pow(a, 2) pow(b, 2)) angle of the hypotenuse float beta rad asin(b c) velocity in pixels per second (used to be 60) c 60 self.velocityFactor windFactor Now accounts for windfactor! parentScene.speedLabel.string NSString stringWithFormat "Speed .1f knots", self.velocityFactor (60 windFactor) 8 x axis velocity component float x c sin(beta rad) y axis velocity component float y c cos(beta rad) adjustments based on position of the this (chaser) sprite and the user's sprite, if chaser is on the right or below the user's sprite it is needed to reverse the velocity vector component x and y if (self.position.x gt point.x) x 1 if (self.position.y gt point.y) y 1 final velocity vector CGPoint velocityVector CGPointMake(x, y) CGPoint newPosition ccpAdd(self.position, ccpMult(velocityVector, delta)) NSLog( "Updating position ", NSStringFromCGPoint(newPosition)) Only update in case new position is in bounds if (newPosition.x lt 0 newPosition.x gt parentLayer.contentSize.width) newPosition CGPointMake(self.position.x, newPosition.y) if (newPosition.y lt 0 newPosition.y gt parentLayer.contentSize.height) newPosition CGPointMake(newPosition.x, self.position.y) self.position newPosition


tunnel effect cocos2d I am looking to create a similar tunnel effect in COCOS2D (iOS). Could anyone suggest any pointers? ref Video 1 ref Video 2 Till now I have tried with several ring shape sprites with decreasing scale and positioned center to a same point and keeping Z decreasing as well for each smaller sprite. With that, animating it with CCScaleTo and changing the size to 2.0 with animation duration but it does not come anyway near to the tunnel effect shown in the reference. Thanks, sam


Manually remove inactive CCParticleSystem from scene? When using particle systems that have a lifetime, with CCParticleSystem and its derived classes, should I manually remove the finished systems from their parent nodes once the particle animations are complete? Or this is done automatically? I don't want to leave dead particle systems in my scene, for obvious reasons.


Sprite Body can not stop Hey i have issue regarding jump sprite body. In my code i am using moveLeft and moveRight Button and when i am press moveRight Button using following code if (moveRight.active YES) b2Vec2 force b2Vec2(4,0) ballBody gt SetLinearVelocity(force) Its move perfectly and When i release this Button than sprite body stop using following code else b2Vec2 force b2Vec2(0,0) ballBody gt SetLinearVelocity(force) But when i put this else part then jump can not done. My jump code is following if (jumpSprite.active YES) NSLog( "Jump Sprite") b2Vec2 locationWorld locationWorld b2Vec2(0.0f,4.0f) double force ballBody gt GetMass() ballBody gt ApplyLinearImpulse(force locationWorld, ballBody gt GetWorldCenter()) If i remove else part then jump will perform complete but sprite body can not stop after release button. So what to do?? Thanks in advance


I need some help with stopping individual sound effects in OALSimpleAudio I'm trying to find out how to stop a specific sound effect rather than having to stop all of them. I'm using OALSimpleAudio. I can't seem to find how to do it. simple google searches result in nothing, which means my searches are crap, it's REALLY easy to do and i'm ... stupid p, or it isn't possible. I hope you guys can help me. In the background i have a humming engine sound, but when the object takes damage, the humming sound is stopped, that's not what i want. case kStateTakingDamage CCLOG( "Ship taking damage") self playTakingDamageSound self.characterHealth self.characterHealth 1.0f action CCActionAnimate actionWithAnimation damageAnimation GameManager sharedGameManager stopSoundEffect break (void) playSoundEffect (NSString ) soundEffect self playSoundEffect soundEffect andLoop NO (void) playSoundEffect (NSString ) soundEffect andLoop (BOOL) loop OALSimpleAudio sharedInstance playEffect soundEffect loop loop (void) stopSoundEffect OALSimpleAudio sharedInstance stopAllEffects (id) isSoundPlaying TODO find out how this works


What is the best way to learn Cocos2D? I've messed around with iPhone development for a couple years now. I've done some contract work. I want to get into Cocos2D to develop a game idea that I have. I was wondering what might be the best quickest way to get up in running in cocos2d? I've thought about a book, but I wondering if that is needed? I'm the type of guy that just wants to know what everything does and is suppose to be used for. Any ideas?


How can I load a large tile map with cocos2d? I am try to design a cocos2d game with a big world. The world's tile map is very big, maybe 20 iPad screen sizes worth of tiles. I want to know how to load this using a CCTMXTiledMap? If I directly add it to screen, will it use too much memory? If so, is there a solution to solve this problem?


How to extend Tiled and Cocos2d to create an Isometric map that supports elevation I've been looking and looking and looking, and I cannot seem to find a solution out there for making a game that uses cocos2d and Tiled to make an isometric map that supports elevation. I am not looking for anything super complex... Just maybe 2 or 3 levels of elevation. (Think X Com UFO Defense, or Final Fantasy Tactics) I figure that since I've been unable to find a solution, I'll probably have to extend Tiled or something to support this. For now I'll just stick with level of elevation, but I want to extend the game to support elevation eventually. Will you share with me any good resources that you know? Where should I read to better understand how to accomplish such a thing?


OOP in cocos2d for ios I have been pulling my hair out trying to make an object in cocos 2d that is a CCSprite (with an image) and a CCLabelBMFont. I tried making a CCNode object and I tried making a custom CCSprite object but none of it worked! Can someone show me how to do this? Thanks.


How to create fun and interactive menus with cocos2d? Possible Duplicate How to make animated buttons in a menu with Cocos2d? How do I make fun and interactive menus with cocos2d, all the tutorials are just for simple clickable menus. Can any one help me learn this? It would be see the menu flip or slide away, I know you can do this with scenes but how do I make this with just the menu? Let's say the menu is a bunch of cards and I want them to flip over like the sub menu is on the backside of the card, how would I do this? Or, make the Main menu slide in from the left, right, top or bottom side and then when a button is selected it slides away the same way and switch to a sub menu (settings, Score etc)? Anyone? David


Recommended book for cocos2d? I'm an experienced programmer that recently got into iOS development by working through the big nerd ranch book by Aaron Hillegass and Joe Conway. I loved the way the book was structured in terms of typing in the code and doing the challenges. I'm interested in learning more about iOS gaming and cocos2d, but am a complete newbie in terms of game development design. There are a number of books on amazon on cocos2d, can anyone recommend one in particular?


How do I implement a selectable world map? I want to have a selectable map of the world, preferably zoomable, in a cocos2d project. When I tap on a country, I want that country to be selected so that I can perform some other operations with it. It seems that the best approach would be to use a vector world map, but I'm unsure how to implement this with cocos2d. Other options include using map tiles, but it seems that still would require the implementation of country polygons for tap click detection. Depending on user input, I want to add icons to various countries on the map. What is a good way to approach the implementation of this type of map?


Cocos2d not getting the texture which is added to CCTextureCache using thread I convert the image into texture in a thread using the following line of code to reduce the image to texture converting time. CCTextureCache sharedTextureCache addImage "imageName" But when i retrieve this image from cache i am getting a blank image. If i am calling the above line of code in main thread i am getting the image.


How do I convert the coordinates of a click to a tilemap position? How do you turn a tilemap (produced by TileD) for cocos2d where I can click on individual items and get a callback? Is it just a case of converting captured touch and finding out where it is on the tilemap and then converting that to pixels but that doesn't say what item was clicked on. I have a tilemap of a city with buildings on it, and I'd like to be able to click or press on a specific building, get a callback. What would be the best way to accomplish this?


CCsprite.flipX not working! Here is my function, it makes random point on the ground and makes my sprite go there. If the x position of location is less then position of my sprite, I flip my sprite so it looked left (it looks right by default). But this is not working at all. I tried different flip methods but none work! Please help what is wrong? (void) wander CGPoint rand CGPointMake(CCRANDOM 0 1() 270 , CCRANDOM 0 1() 140 ) float distance ccpDistance( currentSprite position , rand) float speed distance 2 ccTime time distance speed CCAction move CCMoveTo actionWithDuration time position rand if (currentSprite.position.x gt rand.x) currentSprite.flipX YES else currentSprite.flipX NO self runAction move There is no problem with this code. Problem was that I was trying to flip sprite that was a child of my Pet object. When I tried flipping sprite everything worked just fine. If anybody could explain that, would be great.


How to create array with unique sprites? in cocos2d iphone I write the code like this. This displays only one sprite (red colour bubble) with number of times and moving down, but actually I want to display different sprites (different colour bubble) every time and moving down. I also add no of .png images in resource folder of my project. Here I used only 3.png, but I need to display all .png images (different colour bubbles) in my project but I don't know how to get this. Please help me Thank you. Here is the code (void)addTarget CCSprite target CCSprite spriteWithFile "3.png" rect CGRectMake(0, 0, 256, 256) CGSize winSize CCDirector sharedDirector winSize int minY target.contentSize.height 2 int maxY winSize.height target.contentSize.height 2 int rangeY maxY minY int actualY (arc4random() rangeY) minY Create the target slightly off screen along the right edge, and along a random position along the Y axis as calculated above target.position ccp(winSize.width (target.contentSize.width 2), actualY) self addChild target Determine speed of the target int minDuration 4.0 int maxDuration 12.0 int rangeDuration maxDuration minDuration int actualDuration (arc4random() rangeDuration) minDuration Create the actions id actionMove CCMoveTo actionWithDuration actualDuration position ccp( target.contentSize.width 2,actualY) id actionMoveDone CCCallFuncN actionWithTarget self selector selector(spriteMoveFinished ) target runAction CCSequence actions actionMove, actionMoveDone, nil Add to targets array target.tag 2 targets addObject target (void)gameLogic (ccTime)dt self addTarget (id) init if( (self super initWithColor ccc4(255,255,255,255) )) Enable touch events self.isTouchEnabled YES Initialize arrays targets NSMutableArray alloc init projectiles NSMutableArray alloc init Get the dimensions of the window for calculation purposes CGSize winSize CCDirector sharedDirector winSize self schedule selector(gameLogic ) interval 1.0 self schedule selector(update ) return self (void)update (ccTime)dt NSMutableArray projectilesToDelete NSMutableArray alloc init for (CCSprite projectile in projectiles) CGRect projectileRect CGRectMake(projectile.position.x (projectile.contentSize.width 2), projectile.position.y (projectile.contentSize.height 2), projectile.contentSize.width, projectile.contentSize.height) NSMutableArray targetsToDelete NSMutableArray alloc init for (CCSprite target in targets) CGRect targetRect CGRectMake(target.position.x (target.contentSize.width 2), target.position.y (target.contentSize.height 2), target.contentSize.width, target.contentSize.height) if (CGRectIntersectsRect(projectileRect, targetRect)) targetsToDelete addObject target for (CCSprite target in targetsToDelete) targets removeObject target self removeChild target cleanup YES projectilesDestroyed if ( projectilesDestroyed gt 30) GameOverScene gameOverScene GameOverScene node gameOverScene.layer.label setString "You Win!" CCDirector sharedDirector replaceScene gameOverScene if (targetsToDelete.count gt 0) projectilesToDelete addObject projectile targetsToDelete release for (CCSprite projectile in projectilesToDelete) projectiles removeObject projectile self removeChild projectile cleanup YES projectilesToDelete release


Moving a sprite accelerometer Im trying to, in cocos2d for the iPhone, move a CCSprite (in this case "player" up and down (the app is in landscape). How can I accomplish this? I have been unable to do so. ex. (void)accelerometer (UIAccelerometer )accelerometer didAccelerate (UIAcceleration )acceleration player.position.x acceleration.x 10 NSLog( "Accelerometer x value is f n", acceleration.x)


Moving camera in large view In my cocos2d app I was wondering how to make a CCSprite move on the screen but have the screen focused on the CCSprite, so when the sprite moves the view moves with the CCSprite. Is there a tutorial to do this? Thanks


Using pixel art on small high resolution screens I'm making a game and I would like to utilize pixel art as my style. But I faced a problem, modern displays on my target platform (iOS) have extremely high resolution. So if my artist makes me some sprites in 1 to 1 pixel resolution, each character sprite will look like 2x3 millimeters, and that's not what I want. How do I fix this problem? Do i just use 4 pixel blocks as 1 pixel in my art, or there is some other way? Another question, is how do I utilize high crisp display of those devices with pixel art? How do I go with using images on older devices? Do I have to make double assets or downscale upscale some images?


Importance of scripting engine at Cocos2d Game Engine Each Game Engine is different and solves different problems in different ways, so the engine design does vary greatly from engine to engine (even though a lot of principles are shared from engine to engine). Cocos2D is a great product on it s own, but it doesn t expose engine functionality to a scripting Language like Lua, JavaScript etc. My Question How much important to integrate a Scripting Engine at Cocos2d?


What is actually loaded during a game's loading screen? I am at the stage of my game where I have to develop the loading screen. It's actually already there, but I don't know exactly what it should be loading while it's presented. Why would I have a loading scene instead of just going directly to my game scene? I don't even know what else to load besides the textures with the texture SpriteCache. Am I doing the correct content loading? I missing something to load during that loading scene?


How to make and correctly use progress bar in cocos2d iphone? I have a game that uses a progress bar to inform player of level of certain stats of the player. For example hunger, when it starts at zero and slowly adds up to maximum bar. When he eats the hunger reduces. I tried implementing as progressBar, but it works wrong, as the bar expands both ways, and I need it to grow one side only. Also I had hard time setting the bar, since it uses actions. Is there an easy way to do it?


Why the AnchorPoint doesn't affect the CCLayer Positioning? I think there is a difference between the CCLayer and CCNode behavior when I change their AnchorPoint. I will describe what I mean and please somebody explain it. Scenario I start with CCNode CCNode node ... node.setContentSize(ccp(W,H)) 1. node.setAnchorPoint(ccp(0,0)) node.setPosition(ccp(X,Y) This line will move the node in a way that its (0,0) point will be placed at (X,Y). 2. node.setAnchorPoint(ccp(1,1)) node.setPosition(ccp(X,Y) This line will move the node in a way that its (0,0) point will be placeed at (X W,Y H). In other word, this line will move the (W,H) point of the node to (X,Y) In addition to the Positioning, all actions (like Rotating, Scaling) are based on this anchor point. This policy is fair enough and you won't get confused when moving a scaled node (setScale(X)) to some position because the node's position ( and not node's contents!) will not change in the screen after any actions. ( PS We knew that rotating scaling a node will rotate scale internal node contents) Let's continue with CCLayer CCLayer layer ... layer.setContentSize(ccp(W,H)) 1. layer.setAnchorPoint(ccp(0,0)) layer.setPosition(ccp(X,Y) This line will move the layer in a way that its (0,0) point will be placed at (X,Y) 2. layer.setAnchorPoint(ccp(1,1)) layer.setPosition(ccp(X,Y) Unfortunately, This line will move the layer in a way that its (0,0) point will be placeed at (X,Y). Although CCLayer also use the anchor point for scaling, rotating and ... purposes, It does NOT use its anchor point for positioning!!! Question WHY? and How can I have the same CCNode like setPosition() behaviour for CCLayer? PS I've also tried gt ignoreAnchorPointForPosition(true) but it didn't help. ( cocos2d x version is 2.2.3)


Is it better to preserve scenes in memory or recreate them every time I need them? I am using Cocos Builder to create scenes using sceneWithNodeGraphFromFile owner . Now I have doubts about whether it's better, on iOS, to save some memory or CPU cycles. In other words I have two options First, I could do lazy initialization of scenes without removing them from memory, like this (CCScene ) myScene if(! myScene) myScene CCBReader sceneWithNodeGraphFromFile "MyFile.ccbi" return myScene Then I always call self.myScene and I possibly set myScene to nil if the app receives a memory warning. I never remove a scene from the director, I just push without cleaning. Or, I could initialize a new scene every time. I'd call sceneWithNodeGraphFromFile owner every time that I need to push a scene, popping and cleaning it from the director and creating it again if I need it. Which should I prefer and why?


How to store level information on iOS Let's imagine I have a breakout game. I make a level like this For columns lt max columns For rows lt max rows Create sprite from file, put it on some position based on current column and row, put it into array of objects. Now, imagine I have 100 levels and I want them to be different. What tools should I use to ease my life? How do I load a level from file? Maybe a plist?


I need some help with stopping individual sound effects in OALSimpleAudio I'm trying to find out how to stop a specific sound effect rather than having to stop all of them. I'm using OALSimpleAudio. I can't seem to find how to do it. simple google searches result in nothing, which means my searches are crap, it's REALLY easy to do and i'm ... stupid p, or it isn't possible. I hope you guys can help me. In the background i have a humming engine sound, but when the object takes damage, the humming sound is stopped, that's not what i want. case kStateTakingDamage CCLOG( "Ship taking damage") self playTakingDamageSound self.characterHealth self.characterHealth 1.0f action CCActionAnimate actionWithAnimation damageAnimation GameManager sharedGameManager stopSoundEffect break (void) playSoundEffect (NSString ) soundEffect self playSoundEffect soundEffect andLoop NO (void) playSoundEffect (NSString ) soundEffect andLoop (BOOL) loop OALSimpleAudio sharedInstance playEffect soundEffect loop loop (void) stopSoundEffect OALSimpleAudio sharedInstance stopAllEffects (id) isSoundPlaying TODO find out how this works


Cocos2D TileMap performance question I ve got a question regarding TileMaps. Each level in my game is going to be determined by the length of the tile map. I would like to create a map that will be about 5 mins (in length) long. I want to add depth to my map so I will be making individual layers to create that depth illusion via ParallaxNode. Each independent layer is going to be scrolling automatically at different speeds however the ground layer is going to be scrolling the fastest thus increasing its length being a map that long and the ground layer being longer. Will that bring performance in my game to it's knees?


How to make Snake Body in Snake Game? I'm new in cocos2d and game dev. I'm still learning in game dev. My goal is to make one game like Doodle Grub. But problem is snake body. I wrote like following (void)update (ccTime)delta NSLog( " f", GameScence sharedGameScence .playerVelocity.y) CGPoint tmp self.position float tmprotation self.position GameScence sharedGameScence .WormHeadPos GameScence sharedGameScence .WormHeadPos tmp tmprotation self.rotation self setRotation GameScence sharedGameScence .Headrotation GameScence sharedGameScence .Headrotation tmprotation snake is moving but problem is all of the body segments are same position when snake stop. And all of the body segments is so close and can't see segments like Doodle Grub. Any idea or Any suggestion ?


Cocos2d Check if place is free before moving (all objects) Is there a method in Cocos2d like CGRectIntersectsRect, except instead of limiting it to one sprite, it checks for ALL objects?


Stop schedule on gameOver I have 2 events running through time in my game. I want that when gameover starts, this events stops running This is my code (void)onEnter super onEnter self schedule selector(addStars ) interval 1.5 self schedule selector(addBoxes ) interval 2.5 (void)gameOver stop schedule addStars stop schedule addBoxes


Admob banner not getting remove from superview I am developing one 2d game using cocos2d framework, in this game i am using admob for advertising, in some classes not in all classes but admob banner is visible in every class and after some time game getting crash also. I am not getting how admob banner is comes in every class in fact i have not declare in Rootviewcontroller class. can any one suggest me how to integrate Admob in cocos2d game, i want Admob banner in particular classes not in every class, I am using latest google admob sdk, my code is below Thanks in advance (void)AdMob NSLog( "ADMOB") CGSize winSize CCDirector sharedDirector winSize Create a view of the standard size at the bottom of the screen. if (UI USER INTERFACE IDIOM() UIUserInterfaceIdiomPad) bannerView GADBannerView alloc initWithFrame CGRectMake(size.width 2 364, size.height GAD SIZE 728x90.height, GAD SIZE 728x90.width, GAD SIZE 728x90.height) else It's an iPhone bannerView GADBannerView alloc initWithFrame CGRectMake(size.width 2 160, size.height GAD SIZE 320x50.height, GAD SIZE 320x50.width, GAD SIZE 320x50.height) if (UI USER INTERFACE IDIOM() UIUserInterfaceIdiomPad) bannerView .adUnitID "a15062384653c9e" else bannerView .adUnitID "a15062392a0aa0a" bannerView .rootViewController self CCDirector sharedDirector openGLView addSubview bannerView bannerView loadRequest GADRequest request GADRequest request GADRequest alloc init request.testing NSArray arrayWithObjects GAD SIMULATOR ID, nil Simulator bannerView loadRequest request best practice for removing the barnnerView (void)removeSubviews NSArray subviews CCDirector sharedDirector openGLView .subviews for (id SUB in subviews) (UIView )SUB removeFromSuperview SUB release NSLog( "remove from view") this makes the refreshTimer count (void)targetMethod (NSTimer )theTimer INCREASE OF THE TIMER AND SECONDS elapsedTime seconds INCREASE OF THE MINUTOS EACH 60 SECONDS if (seconds gt 60) seconds 0 minutes self removeSubviews self AdMob NSLog( "TIME 02d 02d", minutes, seconds)


Zoom Layer centered on a Sprite I am in process of developing a small game where a space ship travels through a layer (doh!), in some situations the spaceship comes close to an enemy space ship, and the whole layer is zoomed in on the two with the zoom level being dependent on the distance between the ship and the enemy. All of this works fine. The main question, however, is how do I keep the zoom being centered on the center point between the two space ships and make sure that the two are not off screen? Currently I control the zooming in the GameLayer object through the update method, here is the code (there is no layer repositioning here yet) (void) prepareLayerZoomBetweenSpaceship CGPoint mainSpaceShipPosition mainSpaceShip position CGPoint enemySpaceShipPosition enemySpaceShip position float distance powf(mainSpaceShipPosition.x enemySpaceShipPosition.x, 2) powf(mainSpaceShipPosition.y enemySpaceShipPosition.y,2) distance sqrtf(distance) Distance gt 250 gt no zoom Distance lt 100 gt maximum zoom float myZoomLevel 0.5f if(distance lt 100) maximum zoom in myZoomLevel 1.0f else if(distance gt 250) myZoomLevel 0.5f else myZoomLevel 1.0f (distance 100) 0.0033f self zoomTo myZoomLevel (void) zoomTo (float)zoom if(zoom gt 1) zoom 1 Set the scale. if(self.scale ! zoom) self.scale zoom Basically my question is How do I zoom the layer and center it exactly between the two ships? I guess this is like a pinch zoom with two fingers!


Custom Fonts in cocos2d I have tried Hiero but it has NEVER worked for me. Is there an alternative application for creating fonts for cocos2d? Thanks


Jumping a sprite while moving in a Bezier action I'm creating a game and I need the sprite to jump (move up and down basically) while it's moving on a bezier path so it moves vertically while it still follows the path. If I do this while it's moving along the bezier path mySprite runAction CCJumpBy actionWithDuration 0.1 position ccp(0,0) height 10 jumps 1 It jumps vertically but instantly it returns to the position on the path. What I want is to jump relative to the path. Does anyone know anything about it? It would looks something like this The curve is a sequence of CCBezierBy's by the way. Thanks.


Cocos 2D asteroids style movement (iOS) So I have a CCSprite subclass, well call this Spaceship. Spaceship needs to move on a loop, until I say othersise by calling a method. The method should look something like (void)moveForeverAtVelocity method logic The class Spaceship has two relevant iVars, resetPosition and targetPosition, the target is where we are headed, the reset is where we set to when we've hit our target. If they are both off screen this creates a permanent looping effect. So for the logic, I have tried several things, such as CCMoveTo move CCMoveTo actionWithDuration 2 position ccp(100, 100) CCCallBlockN repeat CCCallBlockN actionWithBlock (CCNode node) self moveForeverAtVelocity self runAction CCSequence actions move, repeat, nil self.position self.resetPosition recursively calling the moveForeverAtVelocity method. This is psuedo code, so its not perfect. I have hard coded some of the values for the sake of simplicity. Enough garble The problem I am having, how can I make a method that loops forever, but can be called and reset at will. I'm running into issues with creating multiple instances of this method. If you can offer any assistance with creating this effect, that would be appreciated.


How can I implement a "Nyan Cat" rainbow? I'm currently making a game similar to this Nyan Cat flash game, although I'm using cocos2d. I'm having a hard time trying to make the rainbow effect Currently, every update call I add a piece of rainbow on screen and move it back, having also added it into a special array. When a player changes its y coordinate I rotate all the added spites by a certain calculated value. Honestly, it looks... not perfect and I've been wondering if there is better way?


Recommended book for cocos2d? I'm an experienced programmer that recently got into iOS development by working through the big nerd ranch book by Aaron Hillegass and Joe Conway. I loved the way the book was structured in terms of typing in the code and doing the challenges. I'm interested in learning more about iOS gaming and cocos2d, but am a complete newbie in terms of game development design. There are a number of books on amazon on cocos2d, can anyone recommend one in particular?


CCParticleSystemQuad works as intended every second time I'm using CCParticleSystemQuad for particles, loading it from plist flourEmitter CCParticleSystemQuad particleWithFile "FlourParticles.plist" But it works not every time. Every second or third time I start a game, particles look different from what I've set them up and there are errors saying it couldn't load image. cocos2d CCTexture2D. Can't create Texture. cgImage is nil cocos2d Couldn't create texture for file in CCTextureCache Of course the image is there and the next time i launch game it works as intended. I cannot think of any ways how to debug this error.


How can I stop the next screen from briefly displaying at the start of a CCTransitionFadeTR? I am testing transitions in cocos2d, and am running into a problem. I have a MainMenu screen which contains a button. The idea is that clicking on the button will trigger a CCTransitionFadeTR transition to a WhackMain screen where there is a CCLabelTTF which displays "Hello World". But when I press the button and start the transition, the WhackMain screen appears at full opacity for a moment before the transition from MainMenu to WhackMain begins. The transition appears to be working correctly, apart from WhackMain being visible for a moment before the transition begins. How can I keep this from happening? Here is my code, if it will help identify the problem MainMenu.m import "MainMenu.h" import "WhackMain.h" implementation MainMenu (CCScene ) scene1 'scene' is an autorelease object. CCScene scene1 CCScene node 'layer' is an autorelease object. MainMenu layer1 MainMenu node add layer as a child to scene scene1 addChild layer1 return the scene return scene1 (id) init always call "super" init Apple recommends to re assign "self" with the "super" return value if( (self super init )) CGSize winSize CCDirector sharedDirector winSize Create a label for display purposes label CCLabelTTF labelWithString "Last button None" dimensions CGSizeMake(320, 50) alignment UITextAlignmentCenter fontName "Arial" fontSize 32.0 retain label.position ccp(winSize.width 2, winSize.height ( label.contentSize.height 2)) self addChild label Standard method to create a button CCMenuItem starMenuItem CCMenuItemImage itemFromNormalImage "ButtonStar.png" selectedImage "ButtonStarSel.png" target self selector selector(starButtonTapped ) position the label on the center of the screen starMenuItem.position ccp( winSize.width 2 , winSize.height 2 ) CCMenu starMenu CCMenu menuWithItems starMenuItem, nil starMenu.position CGPointZero self addChild starMenu return self (void)starButtonTapped (id)sender label setString "Last button " CCDirector sharedDirector replaceScene CCTransitionFadeTR transitionWithDuration 2 scene WhackMain scene2 on "dealloc" you need to release all your retained objects (void) dealloc super dealloc end WhackMenu.m import "WhackMain.h" import "MainMenu.h" implementation WhackMain (CCScene ) scene2 'scene' is an autorelease object. CCScene scene2 CCScene node 'layer' is an autorelease object. WhackMain layer2 WhackMain node add layer as a child to scene scene2 addChild layer2 return the scene return scene2 (id) init always call "super" init Apple recommends to re assign "self" with the "super" return value if( (self super init )) create and initialize a Label CCLabelTTF label CCLabelTTF labelWithString "Hello World" fontName "Marker Felt" fontSize 64 ask director the the window size CGSize size CCDirector sharedDirector winSize position the label on the center of the screen label.position ccp( size.width 2 , size.height 2 ) add the label as a child to this Layer self addChild label return self on "dealloc" you need to release all your retained objects (void) dealloc super dealloc end