Tiled Layer question

Hi guys
i've used the TiledLayer class to create a large background with a number of objects on it, i also have a sprite which can move across the tiledlayer.
What i want to know is how can i work out which tile the sprite is on at any given time.
At the moment i'm trying to get it by dividing the sprite's X position by the tile width to get the cell column and the sprite's Y position by the tile height to get the cell row. The problem is that it's not very accurate so is there a better way of doing it.
thanks for any help

If you're using NetBeans, the path of the image file should be relative to the project root. If as you say the image file is in the "src" folder that should bebackgroundImage = Image.createImage("/src/levelOne.png");Other IDEs may treat the path differently.
db

Similar Messages

  • Tiled layer problem in J2me Game

    hi,
    i made a complete map (2d matrix) of a 2d game.
    Then i made a TileLayer class to add this in game.
    then i made another sprite of my game character.
    now i want to check the collision of that sprite with the hurdels which i made in the TileLayer. is their any other way.
    one way is to make saperate sprites of all those hurdles. i don't want this.
    i want my game character to detect all the hurdels in the Tiled layer class.
    hope i have cleared my point.
    please help me
    thanks

    now i want to check the collision of that sprite
    with the hurdels which i made in the TileLayer.Aaqib
    Have you read the javadoc for Sprite?
    public final boolean collidesWith(TiledLayer t,
                                      boolean pixelLevel)Checks for a collision between this Sprite and the specified TiledLayer. If pixel-level detection is used, a collision is detected only if opaque pixels collide. That is, an opaque pixel in the Sprite would have to collide with an opaque pixel in TiledLayer for a collision to be detected. Only those pixels within the Sprite's collision rectangle are checked.
    If pixel-level detection is not used, this method simply checks if the Sprite's collision rectangle intersects with a non-empty cell in the TiledLayer.
    Any transform applied to the Sprite is automatically accounted for.
    The Sprite and the TiledLayer must both be visible in order for a collision to be detected.
    i don think that this question is soo hard.Neither do I, but you have to learn to read the available documentation :-) The javadoc is your friend.
    If you don't have a local copy, it is available on
    http://java.sun.com/javame/reference/apis/jsr118/
    Regards, Darryl
    edit You may need to add one more TiledLayer so that only the hurdles are on the TiledLayer you use for detecting collisions.
    Message was edited by:
    Darryl.Burke

  • Tiled Layer - NullPointerException

    Hi, getting a small problem when initialising a tiled layer object. When I initialise the TiledLayer object "backgroundLayer", it throws a NullPointerException, and the Catch "System.out.println("")" is also being displayed, stating it cannot find the image. The image itself is in the "src" folder for the game, it's a 31 by 61 PNG file named "levelOne.png". I can't figure out why the image isn't being displayed, please help lol.
    Thanks.
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    import javax.microedition.lcdui.Image.*;
    import javax.microedition.media.*;
    import javax.microedition.io.*;
    import javax.bluetooth.*;
    import java.util.*;
    import java.io.*;
    public class Engine extends GameCanvas implements Runnable {
        public Thread thread;
        public LayerManager layerManager;
        public TiledLayer backgroundLayer;
        public Image backgroundImage;
        boolean isRunning;
        public Engine (AwakeMIDlet m) {
            super(true);
            try {
                backgroundImage = Image.createImage("/levelOne.png");
            catch (IOException ioe) {
                System.out.println("Image unable to be displayed.");
            layerManager = new LayerManager();
            backgroundLayer = new TiledLayer(5, 5, backgroundImage, 31, 31);
            isRunning = true;
            int[] cells = {
                1, 2, 2, 2, 1, // Top
                1, 0, 0, 0, 1,
                1, 0, 0, 0, 1,
                1, 0, 0, 0, 1,
                2, 1, 1, 1, 2
            for (int i = 0; i < cells.length; i++) {
                int column = i % 5;
                int row = (i - column)/5;
                backgroundLayer.setCell(column, row, cells);
    backgroundLayer.setPosition(0, 0);
    layerManager.append(backgroundLayer);
    public void go() {
    thread = new Thread(this);
    thread.start();
    public void run() {
    Graphics g = getGraphics();
    while(isRunning = true) {

    If you're using NetBeans, the path of the image file should be relative to the project root. If as you say the image file is in the "src" folder that should bebackgroundImage = Image.createImage("/src/levelOne.png");Other IDEs may treat the path differently.
    db

  • Rendering a large (Tiled) layer into the camera roll

    Hi,
    Wonder if anyone can help? I've got a very large tiled layer that I'm trying to take a screen shot of. Unfortunately it is a little too large for the normal method (renderInContext, UIGraphicsGetImageFromCurrentImageContext, UIImageWriteToSavedPhotosAlbum etc.) and the app runs out of memory.
    Does anyone know of a way to achieve this? I was considering breaking the job up into multiple 'captures' - but I can't find a way to render anything but the entire layer - it would have been handy if renderInContext took a rectangle as a parameter!
    Thanks for you assistance.
    Craig

    Hi,
    Try to drag your videos to the iPhone photos folder in iPhoto. Should work.
    If it doesn't help, you can always upload your files to dropbox or something similar and later download them on your iPhone.
    Hope it helps.

  • Tiled Layer grinds everything to a halt

    I have a tiled layer which is meant to act as an overlay to a game and represents the screen being filled up with scungy "water"..
    I calculate the number of rows and columns I need and create the tiled layer without assigning any tiles (i.e) they are empty.
    The tile is a single image 5 x 5 pixels. It is a semitranslucent png-24 file
    As the game progresses I gradually fill up a row in the TL with the tile index 1 using a loop and setCell().
    Then at the end of a stage, it comes down again, as though draining using a loop and setCell and a tile index of 0 (sfx to be applied later).
    The problem is that as the screen progressively fills up, the game gets slower and s l o w e rrrrrrrr, then miraculously speeds up again once the tiles are emptied.
    As an experiment I tried it at different levels in the layerManager stack and the same thing happened, even when it was behind the background layer.(and thus presumably not rendered) I also tried it with the exact same code except to change the fill it up code to use a tile index of 0 and the speed was not degraded.
    Do you have any solutions as I need to keep the effect as I have lots of scummy things blobbing about in the "water".
    Your help would be most appreciated
    Kathydb

    How did you upgrade? Did you clean-install or install on top of your previous system? DId you install anything else with the upgrade?
    Do you have any older Aperture plug-ins, that might not be compatible with Mt. Lion and cause problems?
    Do you see the slowness with any Aperture library or only with your main library?
    Try two basic tests to narrow down the problem:
    Launch Aperture while you are holding the shift-key down. This will defer the generation of previews. Is Aperture now more responsive?
    Launch Aperture on a new, empty library and import a few image files. Does Aperture work well on a new library?
    If the first test will make Aperture responsive again, you may have imported bad media files that need to be removed from your Aperture library, or you have missing or incompatible video codecs installed.
    If the second test will make Aperture responsive again, but the first not, your Aperture library may need repairing, see: Repairing and Rebuilding Your Aperture Library: Aperture 3 User Manual
    If none of the above will work, lauch the Console app from Applications > Utilities.
    Check in the Console window, if there are error messages, when Aperture appears to be hanging.
    Post them here.
    Regards
    Léonie

  • Set Text of Layer Question

    A Very Easy Question.
    I attempt to "set text of layer." I click on the plus sign on
    the behaviors window, and set text to layer. A cute little box pops
    up. In the Layer drop down box is a host of "unnamed
    <span>"s. None of my divs are listed. In the body of this
    page are Plenty of ID'd divs. I have named layers out the wazoo.
    Why Are My Named Layers Not Listed In the Layer Drop Down
    Box?

    > seen it done many times over in rss readers, although
    when I look at the
    > page
    > source I secretly hope that it's not as complicated as
    it appears.
    It would depend entirely on your level of HTML expertise.
    One way to solve the problem would be to use an IFrame to
    contain the
    external content on the page, but a frame is a frame is a
    frame. By that I
    mean that IFrames usually provide all the user problems that
    frames do.
    > With the accordion widget I'm using as the main visual
    feature of the site
    > I'm
    > creating, I find it unnacceptable to think I'll have to
    reload the entire
    > page
    > every time a user wants click on something to view
    information; I thought
    > programming like that was a thing of the past.
    Linking from one page to another is how static HTML pages
    work. Having a
    single page to display multiple content elements as loaded
    from a database
    requires that the page return to the server to fetch new
    content from the
    database on each click. Either method requires a page
    refresh.
    Linking to content that is placed within an IFrame doesn't
    require this page
    refresh, but carries other disadvantages as mentioned above.
    Does that help at all?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "iiinsomniiiac" <[email protected]> wrote in
    message
    news:[email protected]...
    > Well, my apologies for not knowing exactly what you mean
    by
    > "round-trip"ing -
    > but - I suppose I'm simply looking for the easiest way
    to do just what I
    > explained: an onclick event that loads an html file into
    a div or td.
    > I've
    > seen it done many times over in rss readers, although
    when I look at the
    > page
    > source I secretly hope that it's not as complicated as
    it appears.
    >
    > With the accordion widget I'm using as the main visual
    feature of the site
    > I'm
    > creating, I find it unnacceptable to think I'll have to
    reload the entire
    > page
    > every time a user wants click on something to view
    information; I thought
    > programming like that was a thing of the past.
    >

  • G4 DVD Dual Layer question

    I have a 14" G4 1.07GHz iBook with a Non DVD Burning CD/CDR/CDRW/DVD drive. My question is, will it READ a dual layer DVD? Thanks!

    Hhmmm...let me know if it works for you. I have (I think) the exact same setup, and my drive spits out dual discs. We bought Bruce Springsteen's The Seeger Sessions, which is a dual disc, and I had to resort to alternate methods to import the songs into my iTunes library. I Googled after having the problem and found others who had the same problem.

  • Hey so I have a layer question

    Okay so I want to add a background from one of the generators in the library and I want to add text on top of it. okay heres my question: How do I make it so that everything on that flat layer will stay there? For example when I go into 3D Mode with the active camera I want to be able to move that multilayered file as one? ME ENTIENDES??? I hope so one knows i dont think this is that complex.

    hi,
    if there is distance between your text and background, maybe their 'z' space parameter is different?
    to flatten a layer you can select group that all the layers are in, and head over to the inspector, click on the tab called group and check the flatten checkbox.
    hth
    adam

  • RPD Business Model Layer Question

    I have multiple fact tables that has the dimension table values like Customer Id, Status, Customer Class in the fact table itself. I added the fact as logical table source to the dimension table in BMM layer. But the problem I have when I try filter on customer id in Answers it hits the fact table that has been added as LTS and not the dimension table.
    Is there any way that I can force the filter to go to the dim table instead of the fact table?
    Thanks,
    Mrinalini.

    OK so you were absolutely correct - not being able to see/use the newly created subject area in Answers was a separate issue which i only fixed this morning :)
    I recreated the multi-source business model and for anyone with this same question ill explain the steps i took (maybe one of the steps is my problem)
    1. Created 3 databases in the Physical layer (each with a separate data source) using a stored procedure to obtain the data.
    - I am using the same for each and the variables are only set up once and set to dashboard prompts.
    exec p_RetrievePlan_inq 'VALUEOF(NQ_SESSION.StartDate)', 'VALUEOF(NQ_SESSION.EndDate)','VALUEOF(NQ_SESSION.Var1)','VALUEOF(NQ_SESSION.Var2','VALUEOF(NQ_SESSION.Var3)','VALUEOF(NQ_SESSION.Var4)','VALUEOF(NQ_SESSION.Var5)'
    2. Dragged 1 database to Business Model and changed its name. This created the columns and source in the Business Model.
    3. Dragged the other 2 db tables over to the '*Sources*' folder in the business model.
    4. Ensured the "This source should be combined with other sources at the level" checkbox was checked for all sources.
    5. Ensured that the columns in Business Model each had 3 sources attached to the coulmn.
    6. Dragged this to the Presentation Model.
    7. Created a report / prompts based on the subject area.
    When i ran the report, expecting to pull back information from all databases based on a date range, only information from the first database was returned. Is it something wrong with the setup? It is pulling back information but only from the database that i first pulled over to the Business Model.
    Also - you mentioned it would do a union of the tables so im guessing that even though it found data for the date range in the first table it would still go to the other tables with the same date range?

  • Belated CS3 Layer Question

    Hello,
    I apologize for asking a question about CS3, but that's what I happen to be using at the moment. How do I unlock the initial background layer or create new layers when editing, say, a .png? In previous versions, that layer could be unlocked just by double-clicking and setting the layer to Layer 1, and creating new layers would automatically change the image to a .psd while it was being worked on.
    I can't believe that I'd actually have to make a new image and copy/paste everything to it; I must just be missing the way to unlock the layer or have my settings set incorrectly.
    Thank you for your time

    goldsunstar wrote:
    I apologize for asking a question about CS3, but that's what I happen to be using at the moment. How do I unlock the initial background layer or create new layers when editing, say, a .png? In previous versions, that layer could be unlocked just by double-clicking and setting the layer to Layer 1, and creating new layers would automatically change the image to a .psd while it was being worked on.
    I can't believe that I'd actually have to make a new image and copy/paste everything to it; I must just be missing the way to unlock the layer or have my settings set incorrectly.
    You still double-click on the layer in the Layers Palette. You can also right-click or bypass the renaming step with Alt-click.

  • ORDDM Derived Layer Question

    This is a question regarding best practices. The ORDM tutorial from Oracle (http://st-curriculum.oracle.com/tutorial/ORDMTutorial/player.htm) states for the ORDM Derived Layer:
    "The Derived Data Model uses a low-level combination of base tables to provide information that can only be derived from base table data".
    And the Oracle Documentation (http://docs.oracle.com/cd/B19306_01/bi.102/e14480/intro.htm) states: "The Derived layer stores information derived from the Base and Reference layers"
    Am I right in saying that according to the layered architecture of the ORDM data model, we should populate the derived layer purely from the 3NF Base Tables, Lookups & Reference Tables?
    Specifically, having a Derived Table in the Derived Layer populating another Derived Table is a violation of standards. Is this a correct assumption?
    Thomas Hefter
    Oracle Support Services on behalf of a customer
    Edited by: user791903 on Aug 16, 2012 1:10 AM

    this is correct. You could have a table or materialized view based on a derived table, but we would call that an aggregate, not derived.

  • Shape layer questions

    I’m a web designer that’s used to using Illustrator for all my work. Recently many of my new jobs want me to work in Photoshop, so I’m getting back up to speed with it. I have a  few nagging issues that I haven’t been able to figure out:
    With the direct selection tool, how do I select a small shape that’s overlapping a larger shape? For example, a small line on top of a large rectangle. When I try to do this Photoshop automatically makes me select the larger shape in the background. I have to zoom in super close and individually shift-select each corner of the smaller shape before I can move/transform/whatever it. This gets tedious and slow real fast!
    Recently in a document I’m working in, whenver I make a new shape it automatically adds a bunch of layer styles like drop shadow, stroke, etc. These styles aren’t turned on, but it adds unecessary styles to my layers and my client is very strict about recieving only super clean .psd’s.
    How do I make a line that is truly 1px stoke width? My lines seem to always start out as fuzzy 2px worms until I zoom in and surgically make them 1px. Again, what a waste of time! is there some sort of antialiasing setting that I need to turn off?
    Thanks!

    1. With smaller shapes that are difficult to select, try selecting their layer first. If you are not sure which layer, switch to the Move tool (V), hold Ctrl and click on the small shape. With the default behavior in Photoshop you should be able to select the layer and then use the Direct selection tool to select points on the vector path of the small shape. If you want to just move the entire shape when its the only path on a layer, aside form using the Path Selection tool (black arrow), you can just use the Move tool (V) to change the position of the layer. If you have to deal with a lot of shape layers that you just want to click and move, enable the Auto Select for the Move tool in the Properties bar. Then holding Ctrl while using the tool will toggle to its non - Auto Select mode.
    2.On the Tool's property bar under the main menu, make sure the chain button is not pressed then click on the Style swatch or arrow to the right of the chain button to open the style swatch popup and from its menu there choose No Style. Next shape layer you make will not have the current style automatically applied. 
    3. I'm using CS5 on a pc and creating 1 px straight line with the Line tool is buggy with its alignment to grid. The Line Tool draws lines in Shape mode as rectangle vector paths. The difference between the Rectangle Tool and the Line tool is that the Line tool aside from having a Weight attribute, it draws the rectangles starting from the middle if its side. In order to snap it to grid you have to set the grid in the settings to Gridline every 1 pix and Subdivisions 2. If properly working this is supposed to solve your problem if you enable snap to grid and draw your lines starting in the middle of a pixel. The problem is that this doesn't work properly with the Line Tool which does not snap perfectly to the grid. The work around is to draw your lines with the Line Tool in Fill Pixels mode which has an Anti-aliasing option that you can turn off.
    Another alternative for drawing lines on raster layers without anti-aliasing is to use the Pencil tool and hold Shift while dragging with it. The Pencil Tool in Photoshop is the same as the Brush tool but without anti-aliasing. I think more proper name would be non - anti-alised brush.

  • Levels/Layer Question. HELP!

    Okay. So I use Elements 6.0 to create graphics and such. I know, kinda geeky. But all of a sudden, when I try to create layer masks (since elements does not have the mask tool), it doesn't work like it used to. Here is an example:
    So I start out with two layers, as you can see. http://i873.photobucket.com/albums/ab298/WhoaitsTehya/Picture2-2.png
    Then, I make a levels chart, and group the picture to the levels. http://i873.photobucket.com/albums/ab298/WhoaitsTehya/Picture4-1.png
    But then I get this: http://i873.photobucket.com/albums/ab298/WhoaitsTehya/Picture3-2.png
    It cuts off most of my picture! I don't know why, but for some reason the dimensions of the photo behind it cut the other photo to shape it. (Does that make sense?) I'm so confused and frustrated. I've tried figuring it out, but nothing seems to work. What did I do and what can I do to fix it?
    If I'm sounding like a babbling idiot and do not make sense, tell me so that I can try to explain it better.
    Thank youu!

    To get that to blend those two photos stacked like that, fill layer 1 with a solid color. In the mask, drag out a gradient using the reflected gradient option (black to transparent) in the middle of the mask. I doctored your screen shot to show how the layers should look to get the image layer 3 + image layer 2 to transition in the middle. (Note: Hold the shift key in when you drag the gradient to make the gradient drag at out even.)

  • Business Objects XI 4.0 Semantic Layer Questions

    Can someone tell me if the new Business Objects XI 4.0 Semantic Layer is an alternative to the use of Universes?
    I.E.  There will be no need for Crystal Reports 2011 Enterprise, and Xcelcius to use Universes at all to access SAP ERP data as well as SAP BI/BW data?
    Is the new direction of SAP not to use Universes to access ERP and BI/BW data at all?
    We are a new SAP NETWEAVER ERP installation with BI/BW and are debating on using
    1)Business Objects 3.2 with Universes
    2)Crystal Reports with custom SQL, Rapidmarts and Data Integrator
    3)Business Objects XI 4.0 with this new Semantic Layer and BI Consumer Services.
    Any suggestions,  pros and cons would be greatly appreaciated.
    We are looking to align ourselves with future SAP Business Objects architectures.
    Thanks in Advance,
    Randy
    Edited by: Randy on Feb 11, 2011 7:58 PM

    Hi Randy,
    Universe is an important part of the Semantic Layer, whether it is version 3.x or version 4.x of SAP BusinessObjects. In version 4.0 (officially known as BI 4.0), you will be using the new Information Design Tool to build universe. It is highly recommended for all of your presentation tools (i.e. WebI, Crystal, Xcelsius/Dashboard, etc) to go through the new Information Design Tool for data (including BW data).
    The BI 4.0 Virtual Launch is scheduled on Feb 23. I suggest you to sign up at http://virtualevents.sap.com/business-analytics/login.aspx.
    By the way, the SAP BusinessObjects does not have a version 3.2. The most current one is version 3.1. You might be confused with the FixPack which is now up to 3.4.
    Hope this helps.

  • Why in a parent layer text disappears, but it is visible in a child layer, a Nested Layer Question

    Hi,
    The text in the parent BLUE layer drops to the bottom of a layer box, which I can see in a Dreamer but not in the browers.
    This happens when I added a child RED layer to the parent.
    Without the child RED layer the text stays at the top of the box in the parent BLUE LAYER.
    What can be done so the text in the parent BLUE layer DOES NOT move the bottom of the layer and becomes visible in the brower?
    cheers,
    Dreamer101.1

    Content is HTML.  Style is CSS.  Custom CSS won't make updating content any faster.
    Start by learning HTML and CSS basics.  DW will punish you if you don't know how to work with Code.
    HTML & CSS Tutorials - http://w3schools.com/
    What suggestion you can make for my project?
    Use default CSS positioning (which is no positioning at all) and align divisions with CSS margins, floats and padding.  If your layout will be complex - several columns per page, consider using a CSS framework or Grid to set-up your web page template.  Some good Grid resources below:
    960 Grid System - http://960.gs/
    Boiler Plate CSS System - http://code.google.com/p/css-boilerplate/
    BluePrint: A CSS Framework - http://www.blueprintcss.org/
    When you are satisfied with the layout, it displays well in all major browsers AND your code passes validation:
    HTML Code Validator - http://validator.w3.org
    CSS  Code  Validator - http://jigsaw.w3.org/css-validator/
    SaveAs as a DW Template (.dwt).  Then add some editable regions for content that will change from page to page.
    More on DW Templates -
    http://www.smartwebby.com/web_site_design/dreamweaver_template.asp
    http://www.smartwebby.com/web_site_design/server_side_includes.asp
    Good luck with your project,
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

Maybe you are looking for

  • Loading data from SQL server 2000 to Oracle using OWB 10.2

    Hi All, I have to move data from SQL server to Oracle using OWB. Any idea how to connect to SQL Server thru the OWB design centre console. There is no detail available in the documentation. OWB cocumentation says that "OWB Integrator for Oracle DB &

  • WLC 7.4 and Flexconnect AP support

    Hi all, Forgive me for not finding it on my own since I am sure it exists. Does anyone have a link to a support chart that shows where support for APs stops on WLC 7.4 code? Specifically, while running APs in Flexconnect mode? Thanks in advance

  • Cs5 Bridge won't recognize Nikon raw file (NRW) from Coolpix P340.

    I want to upload my RAW (NRW) files from my Nikon Coolpix P340 but Bridge CS5 doesn't recognize these as readable. Is there an update available from either adobe or Nikon that anyone is aware of? Thanks.

  • Tracks listed but don't play

    I have created a playlist that includes some spoken tracks. All of the tracks play as intended through itunes. However, when I sync my ipod, all tracks show up but not all of the spoken tracks play. They were all downloaded from the same site and are

  • What do I do if I forgot my iPad password and I have find my iPad with my iPhone?

    Last night, while I was very tired, I was going to change my password on my iPad. I did, and then fell asleep and now I can't remember he password. I have my iPad connected to my Find My iPhone/iPad and I was going to try to see of I could set a NEW