0 Favourites

Construct won't let me create an object!

This forum is currently in read-only mode.
  • So I am working on a map editor for another project. Right now I have a box with two edit boxes where you enter how many blocks high and how many blocks across you would like a map to be. This part works just fine.

    In order to scroll larger maps I want to create a sprite in the middle of the map. Preferably the sprite would create directly on top of a box and move only precisely on top of each tile.

    Now here is my problem.

    I have two variables (X2 and Y2, X and Y were somehow cursed which I won't get into) that store how many blocks high and across the map is. I create an event to create the sprite object like so:

    create object Sprite at

    X position:

    int('X2' / 2) * Box.Width

    Y Position:

    int('Y2' / 2) * Box.Height      

    I hit Finish, there are no errors, but the event simply will not appear. If I create an object with no X and Y parameters and then put them in manually after the event appears, it will disappear immediately.

    What have I done to anger Construct so? I am still not very adept at using Construct, but I've done enough tutorials and examined enough .caps and even made a functional game and have found nothing to suggest that I've done anything wrong.

    I've included the .cap and HD quality sprite

    filefactory.com/file/2jirwdsdwjjt/n/char_png

    filedropper.com/mapeditor

    I apologize for not having named anything... This is the second time I've restarted this and I'm just trying to see if this sort of thing is actually possible to do.

    Any suggestions on an alternate way to do this would be appreciated too. I've searched but not found anything. Help!

  • I didn't open your cap but with global variables use global('X2') instead of the shorthand 'X2', which only works for private variables.

  • I'm not sure if that was the issue, I think deleting the .persist file let me do it, but anyways I suppose it wouldn't have worked without that. Thanks R0J0hound!

    I do have another question that I now can't seem to figure out. I'm using an array to populate my map with boxes, but it seems to hit an arbitrary limit, and this seems to be a height thing. If I tell it to make a map 100 x 100, it will be 100 boxes wide, but only 96 tall... even though it still re sizes the layout to 100.

    I have absolutely no idea what's going on. I've re uploaded my new cap in the original post.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Use the "Clear Array with 0" action after you re-size the array. 96 is the initial y size of your array, it seems that when you make the array bigger the new array cell don't have a value.

  • That seemed to be what was going on but I wasn't able to test that in an effective enough way to be sure.

    Anyways, that fix worked perfectly. Thank you for all of your help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic Locked topic
0 Favourites
Construct 3 any news?
889 125,615
uzumiapps's avatar
uzumiapps
Unread hot topic
353 32,097
yojona's avatar
yojona
Unread hot topic
313 26,494
Juryiel's avatar
Juryiel