[Request] Bound to Viewport Behavior

Post your work in progress addons and get feedback

Post » Sat Mar 15, 2014 5:52 am

Since there is a bound to layout behavior, why not a bound to viewport behavior? it would help with making games for multiple screen sizes.

That or what about a stretch canvas to viewport plugin? I have an HTML5 website editor and that's probably one of my favorite features.
B
3
S
1
Posts: 39
Reputation: 405

Post » Sat Mar 15, 2014 7:20 pm

B
84
S
46
G
25
Posts: 530
Reputation: 21,570

Post » Sat Mar 22, 2014 8:06 pm

@digitalsoapbox

Little to nothing to do with bounding players to the viewport.
B
3
S
1
Posts: 39
Reputation: 405

Post » Mon Mar 24, 2014 10:45 am

Every tick set position to
X : clamp( sprite.X, sprite.width / 2 , ViewportRight(0) - sprite.width/2)
Y : clamp( sprite.y, sprite.height / 2 , ViewportBottom(0) - sprite.height/2)
B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Post » Mon Mar 24, 2014 11:12 am

Noncentz705 wrote:Every tick set position to
X : clamp( sprite.X, sprite.width / 2 , ViewportRight(0) - sprite.width/2)
Y : clamp( sprite.y, sprite.height / 2 , ViewportBottom(0) - sprite.height/2)


To be more accurate:

If the sprite has his origin at the center:

set position to
X : clamp( Self.X, ViewportLeft(Self.LayerName)+Self.Width/2 , ViewportRight(Self.LayerName) - Self.Width/2)
Y : clamp( Self.Y, ViewportTop(Self.LayerName)+Self.Height/2 , ViewportBottom(Self.LayerName) - Self.Height/2)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123


Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests