Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / help with editor

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 28th Mar 2013 15:28
Ok, I had to rewrite the editor after encountering bugs from gods knows where but probably from my own coding errors!
So everything works well like before up to the point of using setviewoffset, the pointer/mouse position is wrong and I don't even know then if I am correctly placing the sprites,i have included the project folder if anyone can help..tnx

Hail to the king, baby!

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Mar 2013 16:28 Edited at: 28th Mar 2013 16:41
the setviewoffset is just the position of a magnifier.
the sprites have the same position.
screentoworld give you the sprite position from mouse pointer.
and the getspritehit want the original position too.
for better understanding just print() the values on screen
and calculate it once at click and not scattered.

this look strange:
brick[id2].xloc = x1*gridx-scrollx
brick[id2].yloc = y1*gridy-scrolly
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 28th Mar 2013 19:01
SetViewOffset

Description

Offset the screen viewport relative to the world, for example a view offset of 0,20 will move the screen down by 20 pixels showing any sprite that was previously positioned just off the bottom of the screen. This can be useful for scrolling games where you want to move the view across a level.


surely I am using what I need? I simply want a larger player area but the pointer position is wrong



btw I had pasted it wrong there but was just trying to use code from another project, that function should be like this:




Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Mar 2013 20:20
this looks strange too:
x2=floor(getpointerx()/gridx)
y2=floor(getpointery()/gridy)
x1=screentoworldx(x2)
y1=screentoworldy(y2)

maybe:
x1=getpointerx()
y1=getpointery()
x2=screentoworldx(x1)
y2=screentoworldy(y1)
x3=floor(x2/gridx)*gridx
y3=floor(y2/gridy)*gridy
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 28th Mar 2013 22:11
tried it, doesn't help at all, surely the setviewoffset is the correct thing I need though right?!

Hail to the king, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 29th Mar 2013 10:50 Edited at: 29th Mar 2013 10:53
and please use only id's returned from create functions
also at loading level
createsprite(brick[n].spritenumber,brick[n].imagenum)
=
brick[n].spritenumber=createsprite(brick[n].imagenum)

shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 31st Mar 2013 15:59
ah! now i see, thanks a lot man.. again

Hail to the king, baby!

Login to post a reply

Server time is: 2024-05-06 05:19:56
Your offset time is: 2024-05-06 05:19:56