how do I get the more values from objects. I know locationX/Y is Object.PointX(); or Object.PointY()
But I would like to use other values like Zorder, Layer, and Animation.
Also, can someone give me a short example of loading a value from an xml file?
Much appreciated!
Edit: Also, How do I place an object using a specific one of its animations?
I’m making a turn-based hextile game and I’d like to spawn tiles from a single object called HexTile which contains a different sprite for each terrain type
Edit: Also, without having to make an object for each new Tile I place on the map, is there a new value that’s placed on newly placed objects so that I can tell them apart from each other and add new variables to them?
For Example, I want to place a tile then do something like HexTile(thirdplaced).HexX = 1; HexTile(thirdplaced).HexY = 4; HexTile(thirdplaced).HexZ = 5 (So that I can have a location co-ordinates for each new tile I place in game)
When you can write a numeric value, there is a button with a capital sigma (the summation symbol) at right, inside this big calculator you can search for these values and others
Z-order : Object.ZOrder()
Animation : Object.Animation(), available for sprite objects
There is not a way to get the layer, and would be difficult to use them analytically since you can’t create new layers in events. Layers are reserved to some things like a GUI (always on top and immovable).
I owe, but work with XML files is relatively easy, you can use an action to write a value in a file to see how it works, then you can load values and store them in variables, finally, you can use the variables to whatever you want.
EDIT: Ahhh! I remember there is an example that uses it to save and load objects, search for “Level editor.gdg” in the examples folder
Maybe you could change the animation, position the object, and set the old animation:
Well, first of all, when you create a new object, GD asks where to locate it
GD select the object from the event’s conditions, and, when you create a new object, that object is the actual reference.
If you add the action “Create object MyObject at x;y”, and below it add another action “Change the animation of MyObject to 3”, only the created object will change its animation.
The next example create a grid of 5 objects x 5 objects:
I use the actions “Change object position” and “Change global color” to highlight the created object is the actual reference, here is the result:
Thanks! I’m gonna try that out now!
Hmmm I got a problem when I create a Tile, HexTile_Plains for example and I change its Z-Order, the game changes all the sprites from the HexTile_Plains object to the same Z-Order. Is there a way around this? for each sprite to have its own Z-Order?
You can use the conditions to select the correct tile because Game Develop can imagine which tile you are speaking of.
Can you take a screenshot from the events editor?
mmm this is the just of it, I want to change it so it changes Z-Layer according to the Hex location later on but for now, I just want to stop the changing of the z-layer of one sprite from affecting all the sprites of that object
Edit: Also to be more clear, my tiles are all the same size but hill and forest tiles use more of the image space at the top, so it overlaps that’s why I’m trying to have different zlayers for each sprite
Edit: I also wanted to do the same thing with the animation itself. Have only HexTile and then change the animation to 0-7. But that too made all the sprite images the same for all sprites of HexTile
aaaah wait nm, I reread your first post… lol I didn’t do the object position thing… !!! haha I get it now, I’ll fix it up thanks!
Now I have a different problem…
when I use “!= Centre is in collision with Hextile” in the condition, it deletes the old sprite. Leaving only the newest sprite. How do I detect a collision without destroying the previous sprites?
Edit: Also, I can log the co-ordinates of the hex location, I’ve made the the following event variables for it Location.NW_SE; Location.SW_NE; Location.W-E for it.
What I’d like to know is, is there a way I can generate a new variable everytime the player moves into a new location? like x0_y0_z0 = TRUE, x0_y1_x0 = TRUE and so on?
Definitely, if you don’t use an action to remove objects, that should not happen . Maybe the object has moved at the same position of another, looking like has been removed, try to check the number of objects and their position in the debugger: Debugger location
Tip: I can see every tile is located at same position, you could make something like:
Centre is not in collision with HexTile | Variable RandomTiles = Random(19)
| Create object HexTile at 0;0
| Position of TileHex = Centre.PointX(Centre);Centre.PointY(Centre)
| Z-Order of HexTile = 1
Variable RandomTiles <= 5 | Animation of HexTile = 1
5 < Variable RandomTiles >= 10 | Animation of HexTile = 2
10 < Variable RandomTiles >= 15 | Animation of HexTile = 3
. . .
Since the change of animation is placed in a sub-event, the newly created object remains as the reference object
The events seems fine, I guess there is an event that changes the Centre object position to create tiles in other locations… Maybe the condition “!= Centre collides with HexTile” doesn’t work as you need and/or expect, I don’t know if the condition take in account the whole of HexTiles to launch its actions (It means “Centre is not in collision with any HexTile”, I guess it’s what you need), or if it’s sufficient that Centre doesn’t collide with someone HexTile (it means if you have two HexTile and Centre collides with one, there is some HexTile that doesn’t collide with Centre and the events launch its actions)
It should be possible with the child variables in the format: ParentVariable[“ChildVariable”], there is not other way to create variables “intelligently”/with a variable name, I think
For example: PlayerPositions[“x”+VariableString(posX)+“_y”+VariableString(posY)+“_z”+VariableString(posZ)] = 1
The example should create the variable PlayerPositions.xa_yb_zc if it doesn’t exist (Variable posX = a, poY = b, posZ = c), you can check if a child variable exist too
Finally, while I studying the Python basics read it many times and come to the conclusion that it’s very difficult, under-performance and probably there is a better way to do it, I recommend you try to find alternatives
Heya
I figured out what was happening with my sprites I took a closer look at the example with the tanks, the one where you right click and all tanks turn green, and if you click a single tank then only that tank turns green. I needed to make sure that if I want to edit any variable or attribute of an individual sprite then I must make sure that the condition refers to that object with its position in the event, and not a child event like I was doing.
Yes! The object that satisfies the condition is the object on which the actions are executed. In your case the only thing that differentiates one object from another is its position.
Each sub-event should work over the reference object from its parent event
Condition A: Objects that satisfies the condition A
Sub-condition (B or C): Objects that satisifies the conditions (A and B) or (A and C)