nimos100's Recent Forum Activity

  • nimos100,

    can you show a part of the code using these coordinates? I used them previously but none did not work for me. An object just does not appear. Maybe I am missing something.

    The reason it doesn't work is because you are using a tile coordinate in your creation but it requires a value in (x , y). so to solve that you have to first convert the bullet (x , y) value to a tile value (TileX, TileY) and then you use that value to convert to a (x, y) value so you can place it on the tilemap.

  • By the way, I am thinking of improving the code of locating an object around the tile we hit. For instance, we have a tile and know its coordinates like Tilemap. PositiontoToTileX(bullet.X) , Tilemap.PositionToTileY(bullet.Y). How do we coordinate tiles Up, Right, Left, Down around this tile?

    Since the bullet impact is always at (0,0) in tile value or what to call it, meaning this will always be by default the original tile coordinate of (TileX, TileY) regardless of where on the tilemap the bullet hit. Knowing this and looking at the image below you can see which value to add to this coordinate to get one of the surrounding tiles.

    The reason you can do it this easy, is because you convert the bullets coordinate X,Y to a tile coordinate and therefore its easier to work with.

    So in your case to get the different tiles you just add the correct amount to the TileX, TileY after the conversion:

    Top:

    Tilemap. PositiontoToTileX(bullet.X) , Tilemap.PositionToTileY(bullet.Y) - 1

    Left:

    Tilemap. PositiontoToTileX(bullet.X) - 1, Tilemap.PositionToTileY(bullet.Y)

    Right:

    Tilemap. PositiontoToTileX(bullet.X) + 1, Tilemap.PositionToTileY(bullet.Y)

    Down:

    Tilemap. PositiontoToTileX(bullet.X), Tilemap.PositionToTileY(bullet.Y) + 1

  • I have two type of objects:

    "A" with the variable "1" and "B" with the same variable "1".

    How do I destroy "B" with the Variable "1" if all of the objects "A" with the same Variable are destroyed?

    You can do it like this:

    Int TestForObjects = 0 (Just a local variable for testing)

    For each ObjectA

    ---- if ObjectA.var = 1 set TestForObjects = 1

    If TestForObjects = 0

    ---- Pick ObjectB.var = 1

    -------ObjectB.Destroy

    So if you found any ObjectA with a variable = 1 you change TestForObjects to 1, since it is by default 0 you know that if it goes through all objectA and is still 0 after the loop then there are no objectA with that value. So you can put it in a function and every time an ObjectA is destroyed you call the function. And then you of course just change the 1 to Function.param(0) and pass the value you want to test against to the function.

  • [quote:1rt5t5gc]Strange, but it did not worked for me. Nothing happens except that Bomb object is erased.

    Does it work if you remove the "Wait 3 seconds" ?

  • In general, how can I loop over all instances of a particular type, but use some property of that instance to affect a single object of another type?

    Since there are 2 instances of Object1 and only 1 of Object2, it can't pair them up. What happens is that Object2.CodeSum is equal to the Code value of the first Object1 instance. What I want is a method where I can loop through each instance of Object1 and add its Code to the single instance of Object2's CodeSum, without trying to pair them up.

    Sorry I fail to see the problem.

    In your example you set Object1.code to a random number.

    Then you go through each of them and add it to Object2.Codesum

    To me it seems to work as you want it to? what do you mean with "Without trying to pair them up"?

  • Don't really understand what you are trying to do?

    Where does addTargetPosition(X, Y) come from? And what list are you referring to?

    And when you say use one property of one type to affect another, I think you might have to be a bit more specific. Because you do it by testing a 1+ conditions of one object and if they are true you do something to the other.

    For instant:

    Object_1.color = Green

    For each Object_1

    ---Pick nearest Object_2

    ---Object_2.Destroy

  • You can store it in a variable, array or object etc. whatever you think is best.

    If you are ok at reading English I would suggest that you start reading the following topics in the manual "Variables", "Objects", "Families", "Arrays" they should give you a good idea of how to do it I think.

  • I want to import the files 1 by 1, not all at once. This way they keep overwriting each others, the first sprite takes the same image as sprite 2, etc. Any idea how i can import 1 file at a time and keep the image?

    There are not really any good solution for this i think as its designed this way in C2. The issue have been raised before by other as well. but don't think it will be changed as it doesn't appear to be a problem by Scirra.

    From what I understand and explained simple, it is made this way to reduce download size at the cost of memory in case you actually need to load images during runtime.

    The only way as far as I have figured out to bypass it or workaround it, is to add empty frames to the sprite that need to store the loaded images. And then load each image into its own frame for each sprite.

    So if you want to load 3 images. You sprite need to have 3 frames. then you need to make a counter to make sure that each image is loaded to the correct frame.

    If you need to replace any of these images later on, you have further increase the number of empty frames. Which is where the memory cost starts to add up, because if you for instant want to be able to load 50 images, not meaning 50 images at the same time only, but just load images with the file chooser for a total of 50 times. You have to add 50 empty frames which will be stored in memory even if they are not needed.

    So to make a workaround you need to do the following two things:

    1. You need to know how many images you want to load or allow to be loaded and based on that you have to created empty frames to your sprite that can handle it.

    2. Make a counter that keep track of which frame to load the image too.

    You need to be aware that if you exceed the maximum number of frames and start from frame 0 again then the problem will reappear, so its a trade off between usability and memory use as I see it.

    So the workaround ain't pretty and not effective in anyway, but as far I know the only working one.

  • Problem Description

    This is just a minor bug. Text is missing when C2 UI is changed.

    Attach a Capx

    https://dl.dropboxusercontent.com/u/109921357/C2%20editor%20bug/C2_editor_bug.capx

    Description of Capx

    Sets a text object text value to something.

    Steps to Reproduce Bug

    Drag right side ui bar towards middle. Also happens when middle is dragged.

    Observed Result

    Text in editor disappear

    Expected Result

    That the text would wrap correctly

    Affected Browsers

    C2 Editor

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    r207

  • What i mean is how to set a tile from another tile set..

    As littlestain says, each tile map are an its own object you can't copy a single tile (Graphic) from one to another, if that is what you are trying to do? What you can do is load another tile map when you need to, but it would be a bad approach I think compared to just adding the needed tiles to the map or simply let tiles from Ore map overwrite those on the main tile map.

  • Its a bit difficult to see what you are trying to do, but assume you want to use one tile map to spawn/change something on the other?

    You have to set up some condition for the Ore tile map and then change it for the Main tile. Here is a simple example:

    It uses two tile maps, one with orange boxes and one with green boxes. Based on where the orange boxes are placed I want to place green boxes on the right side of them.

    So the code:

    Using two loops to go through tile map 1, dividing the width and height with 50, because that's the size of the tiles will give me the tile index coordinate of the tile maps.

    Then checking whether the giving tile on tile map 1 = 0 and if that's the case I set the tile right of the selected tile on tile map 2 to a green square.

    You only really need to use positionToTile when you try to place a none tile map object, like a sprite on a tile map or if you want to track mouse position etc.

    If what you are trying is to get a random tile from your Ore map and use it for your main tile map.

    You just have to get the tile index using the same method I used above.

    Tilemap.width / Tile.width

    Tilemap.height / Tile.height

    And if you need to randomize it

    Random(Tilemap.width / Tile.width) etc.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry this is a long post, but I felt like it may come in handy for some.

    Not a bad post, never thought about it like that.

nimos100's avatar

nimos100

Member since 23 Sep, 2012

None one is following nimos100 yet!

Trophy Case

  • 12-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies