_id
int64
0
49
text
stringlengths
71
4.19k
8
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!!
8
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?
8
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?
8
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 ?
8
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)
8
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?
8
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.
8
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?
8
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.
8
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.
8
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.
8
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?
8
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?
8
Which image format is more memory efficient PNG, JPEG, or GIF? Which image format is more efficient to save memory? PNG, JPEG, or GIF?
8
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?
8
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!
8
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?
8
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
8
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?
8
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.
8
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?
8
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.
8
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?
8
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.
8
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.
8
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.
8
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.
8
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.
8
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?
8
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?
8
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.
8
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?
8
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.
8
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.
8
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.
8
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.
8
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?
8
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?
8
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?
8
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?
8
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?
8
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.
8
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...
8
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.
8
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?
8
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?
8
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.
8
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?
8
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.
8
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
8
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?
8
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!
8
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.
8
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?
8
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.
9
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.
9
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
9
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
9
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.
9
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
9
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
9
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?
9
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?
9
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?
9
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?
9
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.
9
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
9
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?
9
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?
9
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.
9
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?
9
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.
9
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.
9
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
9
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)
9
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
9
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
9
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?
9
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?
9
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?
9
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?
9
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)
9
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?
9
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?
9
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
9
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?
9
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 ?
9
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?
9
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
9
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)
9
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!
9
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
9
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.
9
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.
9
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?
9
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?
9
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.
9
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
9
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?
9
How can I cause the latest touch event to interrupt a prior event in Cocos2D? In Cocos2D for iPhone, I want the latest touch event to interrupt another and ignore the last touch. Let me know if I need to elaborate more, but basically my game consists of a lot of finger dragging, and if the player ever switched fingers, there may be some overlap, and for the way things are setup, it may detect it as a new touch. I think I have things almost on the right track, but my third touch does not work correctly. For instance Touch A begins and held Touch B begins and held Touch A let go Touch A begins and held lt This should interrupt Touch B In my delegate I put glView setMultipleTouchEnabled YES because I believe I need multiple touches enabled. In my CCLayer class with my added map and sprite I am using targeted touch delegate (i.e. ccTouchBegan NOT ccTouchesBegan, etc) I am accessing a touch object with touch event allTouches allObjects objectAtIndex 0 , however I don't have much understanding what index is considered the latest touch or even a process to always get the latest touch.