Search Results

Search found 658 results on 27 pages for 'sprites'.

Page 13/27 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • How can I a sprite image from a set of sprites which have different properties for each sprite?

    - by srikanth rongali
    In my application one player and 10 targets are there. Each target appears one after the other (from target1 to target10). It's a shooting game. If we hit the first target then second target will come. The targets have properties like name, speedOfGunDraw, probability to hit the player, speedOfFire. What should I do to make them appear one after the other with these properties. I am using CCMenuItem for the target. I am using a sprite for the player. Please give me idea to do this. Thank You.

    Read the article

  • How to solve the delay problem in animation of sprites ?

    - by srikanth rongali
    My problem is, I did coding for a sprite. It should change it should change it's image from( 1, 2, 3). It should look like count down time to start a game. 1, 2, 3 are 3 png images. But the images are not displayed in equal intervals of time. I mean time between (1 - 2), (2 - 3) is not same. It is random. Please help me with my problem. Help me if there is better solution than what I am doing.(My animation should be like, before any game starts we see count down 1 then 2 then 3 then GO). -(id)init { if((self = [super init])) { [[CCDirector sharedDirector] setAnimationInterval:60.0/60]; [[CCDirector sharedDirector] setDisplayFPS:NO]; CCAnimation* numberAnimation = [CCAnimation animationWithName:@"countDown" delay: 60.0/60]; for( int i=1;i<4;i++) [numberAnimation addFrameWithFilename: [NSString stringWithFormat:@"number_%02d.png", i]]; id numberAction = [CCAnimate actionWithAnimation: numberAnimation restoreOriginalFrame:NO]; id action2 = [CCFadeOut actionWithDuration:0.5f]; CCSprite *number; number = [CCSprite spriteWithFile:@"number.png"]; .... } }

    Read the article

  • How to refactor my design, if it seems to require multiple inheritance?

    - by Omega
    Recently I made a question about Java classes implementing methods from two sources (kinda like multiple inheritance). However, it was pointed out that this sort of need may be a sign of a design flaw. Hence, it is probably better to address my current design rather than trying to simulate multiple inheritance. Before tackling the actual problem, some background info about a particular mechanic in this framework: It is a simple game development framework. Several components allocate some memory (like pixel data), and it is necessary to get rid of it as soon as you don't need it. Sprites are an example of this. Anyway, I decided to implement something ala Manual-Reference-Counting from Objective-C. Certain classes, like Sprites, contain an internal counter, which is increased when you call retain(), and decreased on release(). Thus the Resource abstract class was created. Any subclass of this will obtain the retain() and release() implementations for free. When its count hits 0 (nobody is using this class), it will call the destroy() method. The subclass needs only to implement destroy(). This is because I don't want to rely on the Garbage Collector to get rid of unused pixel data. Game objects are all subclasses of the Node class - which is the main construction block, as it provides info such as position, size, rotation, etc. See, two classes are used often in my game. Sprites and Labels. Ah... but wait. Sprites contain pixel data, remember? And as such, they need to extend Resource. But this, of course, can't be done. Sprites ARE nodes, hence they must subclass Node. But heck, they are resources too. Why not making Resource an interface? Because I'd have to re-implement retain() and release(). I am avoiding this in virtue of not writing the same code over and over (remember that there are multiple classes that need this memory-management system). Why not composition? Because I'd still have to implement methods in Sprite (and similar classes) that essentially call the methods of Resource. I'd still be writing the same code over and over! What is your advice in this situation, then?

    Read the article

  • Z Order in 2D with orthographic projection and texture atlas

    - by Carbon Crystal
    I am working with a 2D game in OpenGL ES and have a question about z-order together with a texture atlas. I am using an orthographic projection because I want pixel-perfect rendering of 2D sprites, however from what I can determine the draw order is really the only thing that will determine which textures (sprites) appear above or below their neighbors. That is, the "z-index" is a function of the order in which the textures are drawn as opposed to the z coordinate on the vertex array being drawn. So.. I have a texture atlas to save binding multiple textures for each draw call but this immediately creates a problem if there is more than one atlas in play. If I need to draw textures from more than one atlas (typically the case if I have too many sprites to fit in a single atlas of a reasonable size), then I can't maintain a "draw order" across atlases unless I want to bind/unbind the atlas textures more than once.. which kinda defeats the purpose. Does anyone have any clues as to what the best approach is here? Currently I'm running under an assumption that I will have to declare different fixed "depths" (e.g foreground, background etc) in my 2D scene and assume that the z-order for sprites at a given depth is the same. Then I can have as many atlases as I need at each depth and simply draw the depths in order (along with their associated atlases) I'd love to hear what other people are doing.

    Read the article

  • What are good sites that provide free media resources for hobby game development?

    - by m_oLogin
    (Note : This question is being transfered from stackoverflow to gamedev.stackexchange where it belongs) I really suck at graphics / music / 3D modeling / animation and it's a must-have when you have a hundred hobby game development projects you're working on. I'm looking for different quality sources on the web that provide free resources. [EDIT] Some resources given by the answers, in bold the biggest resource per section: MODELS TurboSquid archive3d 3Dvia Google Sketchup ShareCG SPRITES OpenGameArt (also contains textures and 3D models) LostGarden (a couple of isometric tilesets) The Protagonist Domain (2 sprite sets) Reiner's Tilesets (also contains a couple of 3D models) Flying Yogi (3 sprite sets) Has Graphics (a couple of links to tile sets) ANIMATED SPRITES The Spriters Resource (mostly sprites from released games) CLIPART / VECTOR BASED Clker OpenClipArt PHOTOS EveryStockPhoto TEXTURES CG Textures OpenFrag MUSIC Jamendo OpSound SOUND EFFECTS FreeSound StoneWashed MySoundFx OTHER PRECOMPILED LISTS FreeGameDev.net

    Read the article

  • 2D Tile-Based Concept Art App

    - by ashes999
    I'm making a bunch of 2D games (now and in the near future) that use a 2D, RPG-like interface. I would like to be able to quickly paint tiles down and drop character sprites to create concept art. Sure, I could do it in GIMP or Photoshop. But that would require manually adding each tile, layering on more tiles, cutting and pasting particular character sprites, etc. and I really don't need that level of granularity; I need a quick and fast way to churn out concept art. Is there a tool that I can use for this? Perhaps some sort of 2D tile editor which lets me draw sprites and tiles given that I can provide the graphics files.

    Read the article

  • Making body (box2d) a sprite (andengine) in Android

    - by Kadir
    I can't make body (box2d) a sprite (andengine) and at the same time apply MoveModifier to sprite which is body. If i can make just body, it works namely the sprites can collide. If I apply just MoveModifier to sprites, the sprites can move where i want. But I want to make body (they can collide) and apply MoveModifier (they can move where I want) at the same time. How can i do it? This my code just run MoveModifier not as body at the same time. circles[i] = new Sprite(startX, startY, textRegCircle[i]); body[i] = PhysicsFactory.createCircleBody(physicsWorld, circles[i], BodyType.DynamicBody, FIXTURE_DEF); physicsWorld.registerPhysicsConnector(new PhysicsConnector(circles[i], body[i], true, true)); circles[i].registerEntityModifier( (IEntityModifier) new SequenceEntityModifier ( new MoveModifier(10.0f, circles[i].getX(), circles[i].getX(), circles[i].getY(),CAMERA_HEIGHT+64.0f))); scene.getLastChild().attachChild(circles[i]); scene.registerUpdateHandler(physicsWorld);

    Read the article

  • Draw on screen border in Commodore 64

    - by Stefano Borini
    Ok. I hope it does not get closed because I have this curiosity since 25 years and I would love to understand the trick. In the commodore 64 the border was not addressable by the 6569 VIC. All you could do was to draw pixels in the central area, the one where the cursor moved. The border was always uniform, although you could change its color with poke 53280,color if i remember correctly. Nevertheless I clearly remember games intros where the border was featured with graphics, like it was fully addressable. I tried to understand how it worked but never got to the point. legends say it was a clever use of sprites, which could, under some circumstances, be drawn on the border, but I don't know if it's an urban legend. edit: just read this from one of the provided links Sprites were multiplexed across vertical raster lines (over 8 sprites, sometimes up to 120 sprites). Until the Group Crest released Krestage 3 in May 2007 there was the common perception that no more than 8 sprites could appear at one raster line, but assigning new Y coordinates made it reappear further down the screen. This is evil.... you beat the raster and reposition the sprite before it gets there...

    Read the article

  • Box2D in Flash runs quicker when drawing debug data than not

    - by bowdengm
    I've created a small game with Box2d for AS3 - I have sprites attached to the stage that take their position from the underlying Box2d world. These sprites are mostly PNGs. When the game runs with DrawDebugData() bening called every update, it runs nice and smoothly. However when I comment this out, it runs choppily. In both cases all my sprites are being rendered. So it seems that it's running faster when it's drawing the debug data additionaly (i.e. my sprites are on the screen in both cases!) What's going on? Does drawing the debug data flick some sort of 'render quick' switch? If so, what's the switch!? I can't see it in the Box2D code. function Update(e){ m_world.Step(m_timeStep, m_velocityIterations, m_positionIterations); // draw debug? m_world.DrawDebugData(); // with the above line in, I get 27fps, without it, I get 19fps. // that's the only change that's causing such a huge difference. doStuff(); } Interestingly, If i set the debug draw scale to something different to my world scale, it slows down to 19fps. So there's something happening when it draws the boxes under my sprites causing it to run quicker.. Cheers, Guy

    Read the article

  • Silverlight Cream for March 11, 2010 -- #812

    - by Dave Campbell
    In this Issue: Walter Ferrari, Viktor Larsson, Bill Reiss(-2-, -3-, -4-), Jonathan van de Veen, Walt Ritscher, Jobi Joy, Pete Brown, Mike Taulty, and Mark Miller. Shoutouts: Going to MIX10? John Papa announced Got Questions? Ask the Experts at MIX10 Pete Brown listed The Essential WPF/Silverlight/XNA Developer and Designer Toolbox From SilverlightCream.com: How to extend Bing Maps Silverlight with an elevation profile graph - Part 2 In this second and final tutorial, Walter Ferrari adds elevation to his previous BingMaps post. I'm glad someone else worked this out for me :) Navigating AWAY from your Silverlight page Viktor Larsson has a post up on how to navigate to something other than your Silverlight page like maybe a mailto ... SilverSprite: Not just for XNA games any more Bill Reiss has a new version of SilverSprite up on CodePlex and if you're planning on doing any game development, you should check this out for sure Space Rocks game step 1: The game loop Bill Reiss has a tutorial series on Game development that he's beginning ... looks like a good thing to jump in on and play along. This first one is all about the game loop. Space Rocks game step 2: Sprites (part 1) In Part 2, Bill Reiss begins a series on Sprites in game development and positioning it. Space Rocks game step 3: Sprites (part 2) Bill Reiss's Part 3 is a follow-on tutorial on Sprites and moving according to velocity... fun stuff :) Adventures while building a Silverlight Enterprise application part No. 32 Jonathan van de Veen is discussing debugging and the evil you can get yourself wrapped up in... his scenario is definitely one to remember. Streaming Silverlight media from a Dropbox.com account Read the comments and the agreements, but I think Walt Ritscher's idea of using DropBox to serve up Streaming media is pretty cool! UniformGrid for Silverlight Jobi Joy wanted a UniformGrid like he's familiar with in WPF. Not finding one in the SDK or Toolkit, he converted the WPF one to Silverlight .. all good for you and me :) How to Get Started in WPF or Silverlight: A Learning Path for New Developers Pete Brown has a nice post up describing resources, tutorials, blogs, and books for devs just getting into Silveright or WPF, and thanks for the shoutout, Pete! Silverlight 4, MEF and the DeploymentCatalog ( again :-) ) Mike Taulty is revisiting the DeploymentCatalog to wrap it up in a class like he did the PackageCatalog previously MVVM with Prism 101 – Part 6b: Wrapping IClientChannel Mark Miller is back with a Part 6b on MVVM with Prism, and is answering some questions from the previous post and states his case against the client service proxy. Stay in the 'Light! Twitter SilverlightNews | Twitter WynApse | WynApse.com | Tagged Posts | SilverlightCream Join me @ SilverlightCream | Phoenix Silverlight User Group Technorati Tags: Silverlight    Silverlight 3    Silverlight 4    MIX10

    Read the article

  • iOS + cocos2d: how to account for sprite's position for the different device dimensions in an universal app?

    - by fuzzlog
    All the questions I've seen regarding iOS universal apps (with or without cocos2d) deal with the "how to add graphics to a universal app". My question is, how does the code need to be written to ensure that the sprites appear appropriately on the screen (given that an iPhone 5's resolution is not proportional to an iPad's resolution)? Is it just a bunch of "if" statements and duplicate code or do iOS/cocos2d provide common function calls that will place the sprites at an appropriate position?

    Read the article

  • cocos2d-x and handling touch events

    - by Jason
    I have my sprites on screen and I have a vector that stores each sprite. Can a CCSprite* handle a touch event? Or just the CCLayer*? What is the best way to decide what sprite was touched? Should I store the coordinates of where the sprite is (in the sprite class) and when I get the event, see if where the user touched is where the sprite is by looking through the vector and getting each sprites current coordinates? UPDATE: I subclass CCSprite: class Field : public cocos2d::CCSprite, public cocos2d::CCTargetedTouchDelegate and I implement functions: cocos2d::CCRect rect(); virtual void onEnter(); virtual void onExit(); bool containsTouchLocation(cocos2d::CCTouch* touch); virtual bool ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event); virtual void ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event); virtual void ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event); virtual void touchDelegateRetain(); virtual void touchDelegateRelease(); I put CCLOG statements in each one and I dont hit them! When I touch the CCLayer this sprite is on though I do hit those in the class that implements the Layer and puts these sprites on the layer.

    Read the article

  • gl_PointCoord always zero

    - by Jonathan
    I am trying to draw point sprites in OpenGL with a shader but gl_PointCoord is always zero. Here is my code Setup: //Shader creation..(includes glBindAttribLocation(program, ATTRIB_P, "p");) glEnableVertexAttribArray(ATTRIB_P); In the rendering loop: glUseProgram(shader_particles); float vertices[]={0.0f,0.0f,0.0f}; glEnable(GL_TEXTURE_2D); glEnable(GL_POINT_SPRITE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); //glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);(tried with this on/off, doesn't work) glVertexAttribPointer(ATTRIB_P, 3, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_POINTS, 0, 1); Vertex Shader: attribute highp vec4 p; void main() { gl_PointSize = 40.0f; gl_Position = p; } Fragment Shader: void main() { gl_FragColor = vec4(gl_PointCoord.st, 0, 1);//if the coords range from 0-1, this should draw a square with black,red,green,yellow corners } But this only draws a black square with a size of 40. What am I doing wrong? Edit: Point sprites work when i use the fixed function, but I need to use shaders because in the end the code will be for opengl es 2.0 glUseProgram(0); glEnable(GL_TEXTURE_2D); glEnable(GL_POINT_SPRITE); glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE); glPointSize(40); glBegin(GL_POINTS); glVertex3f(0.0f,0.0f,0.0f); glEnd(); Is anyone able to get point sprites working with shader? If so, please share some code.

    Read the article

  • Using MVC with a retained mode renderer

    - by David Gouveia
    I am using a retained mode renderer similar to the display lists in Flash. In other words, I have a scene graph data structure called the Stage to which I add the graphical primitives I would like to see rendered, such as images, animations, text. For simplicity I'll refer to them as Sprites. Now I'm implementing an architecture which is becoming very similar to MVC, but I feel that that instead of having to create View classes, that the sprites already behave pretty much like Views (except for not being explicitly connected to the Model). And since the Model is only changed through the Controller, I could simply update the view together with the Model in the controller, as in the example below: Example 1 class Controller { Model model; Sprite view; void TeleportTo(Vector2 position) { model.Position = view.Position = position; } } The alternative, I think, would be to create View classes that wrap the sprites, make the model observable, and make the view react to changes on the model. This seems like a lot of extra work and boilerplate code, and I'm not seeing the benefits if I'm just going to have one view per controller. Example 2 class Controller { Model model; View view; void TeleportTo(Vector2 position) { model.Position = position; } } class View { Model model; Sprite sprite; View() { model.PropertyChanged += UpdateView; } void UpdateView() { sprite.Position = model.Position; } } So, how is MVC or more specifically, the View, usually implemented when using a retained-mode renderer? And is there any reason why I shouldn't stick with example 1?

    Read the article

  • How can I replicate the look and limitations of the Super NES?

    - by Mikalichov
    I am looking to produce graphics with the same limitations / look that in the Super Nes era. I am specifically looking for graphics similar to Chrono Trigger / FF6. It would be a lot easier to do if I had an idea of the resolution / dpi I am supposed to use. I found that the technical specs for the SNES are: Progressive: 256 × 224, 512 × 224, 256 × 239, 512 × 239 Interlaced: 512 × 448, 512 × 478 But even by using these resolutions, it is pointless if I set it at 72dpi, as I will still have possibly very detailed graphics (that is the main thing, I don't want detailed graphics, I want to go pixelated). I figured it might be related to the sprite size limit, i.e.: Sprites can be 8 × 8, 16 × 16, 32 × 32, or 64 × 64 pixels, each using one of eight 16-color palettes and tiles from one of two blocks of 256 in VRAM. Up to 32 sprites and 34 8 × 8 sprite tiles may appear on any one line. This would work for sprites (characters, objects), but what about maps? Are they built entirely from 8x8 tiles? And then, at what resolution is the end result displayed? It might seem like I am giving the question and answers at the same time, but all of these are suppositions I am making, so could someone confirm or correct them?

    Read the article

  • Question on methods in Object Oriented Programming

    - by mal
    I’m learning Java at the minute (first language), and as a project I’m looking at developing a simple puzzle game. My question relates to the methods within a class. I have my Block type class; it has its many attributes, set methods, get methods and just plain methods. There are quite a few. Then I have my main board class. At the moment it does most of the logic, positioning of sprites collision detection and then draws the sprites etc... As I am learning to program as much as I’m learning to program games I’m curious to know how much code is typically acceptable within a given method. Is there such thing as having too many methods? All my draw functionality happens in one method, should I break this into a few ‘sub’ methods? My thinking is if I find at a later stage that the for loop I’m using to cycle through the array of sprites searching for collisions in the spriteCollision() method is inefficient I code a new method and just replace the old method calls with the new one, leaving the old code intact. Is it bad practice to have a method that contains one if statement, and place the call for that method in the for loop? I’m very much in the early stages of coding/designing and I need all the help I can get! I find it a little intimidating when people are talking about throwing together a prototype in a day too! Can’t wait until I’m that good!

    Read the article

  • Fast, accurate 2d collision

    - by Neophyte
    I'm working on a 2d topdown shooter, and now need to go beyond my basic rectangle bounding box collision system. I have large levels with many different sprites, all of which are different shapes and sizes. The textures for the sprites are all square png files with transparent backgrounds, so I also need a way to only have a collision when the player walks into the coloured part of the texture, and not the transparent background. I plan to handle collision as follows: Check if any sprites are in range of the player Do a rect bounding box collision test Do an accurate collision (Where I need help) I don't mind advanced techniques, as I want to get this right with all my requirements in mind, but I'm not sure how to approach this. What techniques or even libraries to try. I know that I will probably need to create and store some kind of shape that accurately represents each sprite minus the transparent background. I've read that per pixel is slow, so given my large levels and number of objects I don't think that would be suitable. I've also looked at Box2d, but haven't been able to find much documentation, or any examples of how to get it up and running with SFML.

    Read the article

  • What is the standard technique for shifting the frames of a sprite according to user input?

    - by virtual__
    From my own experience, I developed two techniques for changing the sprites of a character that's reacting to user input -- this in the context of a classic 2D platformer. The first one is to store all character's pixmaps in a list, putting the index of the currently used pixmap in an ordinary variable. This way, every time the player presses a key -- say the right arrow for moving the character forward -- the graphics engine sees what's the next pixmap to draw, draws it, and increments the index counter. That's a pretty common approach I believe, the problem is that in this case the animation's quality depends not only on the number of sprites available but also on how often your engine listens to user input. The second technique is to actually play an animation every key press event. For this you can use any sort of animation framework you want. It's only necessary to set the timer, the animation steps and to call the animation's play() method on your key press event handler. The problem with that approach is that is lacks responsiveness, since the character won't react to any input while the current animation is still being played. What I want to know is whether you are using one of these techniques -- or something similar -- in your games, or whether there's a standard method for animating sprites out there that's widely known by everybody but me.

    Read the article

  • How can I use an object pool for optimization in AndEngine?

    - by coder_For_Life22
    I have read up on a tutorial that allows you to reuse sprites that are re-added to the scene such as bullets from a gun or any other objects using an ObjectPool. In my game i have a variation of sprites about 6 all together with different textures. This is how the object pool is set up with its own class extending Java's GenericPool class public class BulletPool extends GenericPool<BulletSprite> { private TextureRegion mTextureRegion; public BulletPool(TextureRegion pTextureRegion) { if (pTextureRegion == null) { // Need to be able to create a Sprite so the Pool needs to have a TextureRegion throw new IllegalArgumentException("The texture region must not be NULL"); } mTextureRegion = pTextureRegion; } /** * Called when a Bullet is required but there isn't one in the pool */ @Override protected BulletSprite onAllocatePoolItem() { return new BulletSprite(mTextureRegion); } /** * Called when a Bullet is sent to the pool */ @Override protected void onHandleRecycleItem(final BulletSprite pBullet) { pBullet.setIgnoreUpdate(true); pBullet.setVisible(false); } /** * Called just before a Bullet is returned to the caller, this is where you write your initialize code * i.e. set location, rotation, etc. */ @Override protected void onHandleObtainItem(final BulletSprite pBullet) { pBullet.reset(); } } As you see here it takes a TextureRegion parameter. The only problem i am facing with this is that i need to have 6 different sprites recycled and reused in the ObjectPool. This ObjectPool is set up to only use one TextureRegion. Any idea's or suggestions on how to do this?

    Read the article

  • Pygame Sprite/Font rendering issues

    - by Grimless
    Hey guys. Here's my problem: I have a game class that maintains a HUD overlay that has a bunch of elements, including header and footer background sprites. Everything was working fine until I added a 1024x128 footer sprite. Now two of my text labels will not render, despite the fact that they DO exist in my Group and self.elements array. Is there something I'm missing? When I take out the footerHUDImage line, all of the labels render correctly and everything works fine. When I add the footerHUDImage, two of the labels (the first two) no longer render and the third only sometimes renders. HELP PLEASE! Here is the code: class AoWHUD (object): def __init__(self, screen, delegate, dataSource): self.delegate = delegate self.dataSource = dataSource self.elements = [] headerHudImage = KJRImage("HUDBackground.png") self.elements.append(headerHudImage) headerHudImage.userInteractionEnabled = True footerHUDImage = KJRImage("ControlsBackground.png") self.elements.append(footerHUDImage) footerHUDImage.rect.bottom = screen.get_rect().height footerHUDImage.userInteractionEnabled = True lumberMessage = "Lumber: " + str(self.dataSource.lumber) lumberLabel = KJRLabel(lumberMessage, size = 48, color = (240, 200, 10)) lumberLabel.rect.topleft = (_kSpacingMultiple * 0, 0) self.elements.append(lumberLabel) stoneMessage = "Stone: " + str(self.dataSource.stone) stoneLabel = KJRLabel(stoneMessage, size = 48, color = (240, 200, 10)) stoneLabel.rect.topleft = (_kSpacingMultiple * 1, 0) self.elements.append(stoneLabel) metalMessage = "Metal: " + str(self.dataSource.metal) metalLabel = KJRLabel(metalMessage, size = 48, color = (240, 200, 10)) metalLabel.rect.topleft = (_kSpacingMultiple * 2, 0) self.elements.append(metalLabel) foodMessage = "Food: " + str(len(self.dataSource.units)) + "/" + str(self.dataSource.food) foodLabel = KJRLabel(foodMessage, size = 48, color = (240, 200, 10)) foodLabel.rect.topleft = (_kSpacingMultiple * 3, 0) self.elements.append(foodLabel) self.selectionSprites = {32 : pygame.image.load("Selected32.png").convert_alpha(), 64 : pygame.image.load("Selected64.png")} self._sprites_ = pygame.sprite.Group() for e in self.elements: self._sprites_.add(e) print self.elements def draw(self, screen): if self.dataSource.resourcesChanged: lumberMessage = "Lumber: " + str(self.dataSource.lumber) stoneMessage = "Stone: " + str(self.dataSource.stone) metalMessage = "Metal: " + str(self.dataSource.metal) foodMessage = "Food: " + str(len(self.dataSource.units)) + "/" + str(self.dataSource.food) self.elements[2].setText(lumberMessage) self.elements[2].rect.topleft = (_kSpacingMultiple * 0, 0) self.elements[3].setText(stoneMessage) self.elements[3].rect.topleft = (_kSpacingMultiple * 1, 0) self.elements[4].setText(metalMessage) self.elements[4].rect.topleft = (_kSpacingMultiple * 2, 0) self.elements[5].setText(foodMessage) self.elements[5].rect.topleft = (_kSpacingMultiple * 3, 0) self.dataSource.resourcesChanged = False self._sprites_.draw(screen) if self.delegate.selectedUnit: theSelectionSprite = self.selectionSprites[self.delegate.selectedUnit.rect.width] screen.blit(theSelectionSprite, self.delegate.selectedUnit.rect)

    Read the article

  • OpenGL ES - how to keep some object at a fixed size?

    - by OMH
    I'm working on a little game in OpenGL ES. In the background, there is a world/map. The map is just a large texture. Zoom/pinch/pan is used to move around. And I'm using glOrthof (left, right, bottom, top, zNear, zFar) to implement the zoom/pinch. When I zoom in, the sprites on top of the map is also zoomed in. But I would like to have some sprites stay at a fixed size. I could probably calculate a scale factor, depending on the parameters to glOrthof, but there must be a more natural and straightforward way of doing that, instead of scaling the sprites down when I zoom in. If I add some text or some GUI elements on top of the map, they should definately have a fixed size. Is there a solution to do this, or do I have to leave fixed values in glOrthof and implement zoom/pinch in another way? EDIT: To be more clear: I want sprites that zoom in/out along with the map, but stay at the same size. I have some elements that are like the pins on the iPhone's map application. When you zoom, the pins stay the same size, but move around on the screen to stay on the same spot on the map. That is mainly what I want a solution for. Solutions for this already came below, thanks!

    Read the article

  • How to add/get Sprite to/from UIComponent

    - by user955399
    How to add Sprite to BorderContainer (UIComponent)? var sprite:Sprite = new Sprite(); sprite.graphics.lineStyle(10,0); sprite.graphics.moveTo(40,40); sprite.graphics.lineTo(60,60); mybordercontainer.addChild(sprite); //mybrodercontainer is id of BorderContainer created in mxml This code doesnt work. I cant see Sprite on my BorderContainer. How can I add Sprites on UIComponents, so I can see them? I tried this and it kinda worked: var comp:UIComponent = new UIComponent(); comp.addChild(sprite); myborderconteiner.addElement(comp); But I dont think, that this is a right way to add Sprites to UIComponents. Is there another method to do that? Second problem: When I have few Sprites added to my UIComponent (lines/circles/images or others) how can I receive an object Sprite from that UIComponent, which is containing all Sprites added before to that UIComponent? I need to create Bitmap from that Sprite and do some things. I hope I make myself clear

    Read the article

  • Flex Sprite xy Coordinates

    - by Ian
    Hi, I have a drawing that looks more or less like the attached image. image The orange square is the currently selected selected sprite. The sprites are all draws from coordinates that i receive from XML. var sprObject:Sprite = new Sprite(); sprObject.graphics.beginFill(itemList.c.toString()); sprObject.name = strName; sprObject.graphics.moveTo(iX, iY); sprObject.graphics.lineTo(iX2, iY2); sprObject.graphics.lineTo(iX3, iY3); sprObject.graphics.lineTo(iX4, iY4); sprObject.graphics.lineTo(iX, iX); sprObject.graphics.endFill(); mainUI.addChild(sprObject); // mainUI is a mx:UIComponent g_Sprite.push(sprObject); // array of sprites. What I want to do is the following. If I'm currently on the orange square and I use my keyboard direction buttons (up/down/left/right). I want to deselect the current sprite and select the next sprite in the appropriate direction. The problem I'm having is that I cannot get the x and y coordinates of the drawn sprites. If I look in the array, the x and y coordinates of the sprites are all 0. If I can retrieve that I can write an algorithm to determine the next sprite to select. Any help would be appreciated.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >