Construct won't let me create an object!

For questions about using Classic.

Post » Tue Sep 25, 2012 8:47 pm

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

http://www.filefactory.com/file/2jirwdsdwjjt/n/char_png
http://www.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!crowtongue2012-09-27 17:40:40
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Wed Sep 26, 2012 10:08 pm

I didn't open your cap but with global variables use global('X2') instead of the shorthand 'X2', which only works for private variables.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Thu Sep 27, 2012 5:39 pm

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.
B
7
S
2
Posts: 123
Reputation: 1,061

Post » Thu Sep 27, 2012 7:45 pm

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.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Thu Sep 27, 2012 8:03 pm

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.
B
7
S
2
Posts: 123
Reputation: 1,061


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests