nimos100's Forum Posts

  • Think you need to explain a bit more about what you mean. It a bit hard to understand what you mean with "Object in another object?" Because I don't think you are referring to just overlapping since its the case in both images? or do you mean that the two objects are overlapping a third object and at the same time next to each other?

  • there must be a work around, how can you display 40 different images fetched dynamically without creating 40 objects on stage?

    There are no work around, you can create 40 objects or you can add 40 frames to your object and then make a functionality that load them into the correct frames. Regardless of which way you do it, none of them are going to be pretty.

  • You need to pick the correct health bar as well, you only pick the sprite that is clicked, but C2 doesn't know what health bar you are referring to so it automatically picks all of them.

  • You can try to share the capx

  • Not that I know how to fix it, but does it happen if you run other apps in the debugger?

  • It would be nice if for each looped over all instances or if there were some alternative that did, but for now at least I have found a way

    For each loop through all instances regardless of where they are created editor or runtime.

    If it doesn't it most likely because your picking is wrong somehow I would guess.

    You have to be sure that For each is placed correctly:

    <Object Conditions>

    For each <Object>

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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