Physics distributed
This commit is contained in:
1 parent
8294ec8556
commit
d7acb36f39
5 files changed
+37
-40
No files matched your search
@@ -43,6 +43,7 @@ function newCircularMenu () {
|
||||
menuItem.angle = menuItemInitialValue.angle
|
||||
|
||||
menuItem.initialize()
|
||||
menuItem.container.connectToParent(thisObject.container, false, false, true)
|
||||
menuItems.push(menuItem)
|
||||
}
|
||||
|
||||
|
||||
@@ -121,8 +121,8 @@ function newCircularMenuItem () {
|
||||
|
||||
if (thisObject.canDrawIcon === true && thisObject.currentRadius > 1) {
|
||||
let menuPosition = {
|
||||
x: position.x + thisObject.currentRadius * 3 / 4 * Math.cos(toRadians(thisObject.angle)),
|
||||
y: position.y - thisObject.currentRadius * 3 / 4 * Math.sin(toRadians(thisObject.angle)) }
|
||||
x: position.x + thisObject.container.frame.radius * 3 / 4 * Math.cos(toRadians(thisObject.angle)),
|
||||
y: position.y - thisObject.container.frame.radius * 3 / 4 * Math.sin(toRadians(thisObject.angle)) }
|
||||
|
||||
browserCanvasContext.drawImage(thisObject.icon, menuPosition.x - thisObject.currentRadius, menuPosition.y - thisObject.currentRadius, thisObject.currentRadius * 2, thisObject.currentRadius * 2)
|
||||
|
||||
|
||||
@@ -581,36 +581,6 @@ function newFloatingLayer () {
|
||||
floatingObject.currentSpeed.y = -MAX_SPEED
|
||||
}
|
||||
|
||||
// The radius also have a target.
|
||||
|
||||
if (Math.abs(floatingObject.container.frame.radius - floatingObject.targetRadius) >= 1) {
|
||||
if (floatingObject.container.frame.radius < floatingObject.targetRadius) {
|
||||
floatingObject.container.frame.radius = floatingObject.container.frame.radius + 0.5
|
||||
} else {
|
||||
floatingObject.container.frame.radius = floatingObject.container.frame.radius - 0.5
|
||||
}
|
||||
}
|
||||
|
||||
// The imageSize also have a target.
|
||||
|
||||
if (Math.abs(floatingObject.currentImageSize - floatingObject.targetImageSize) >= 1) {
|
||||
if (floatingObject.currentImageSize < floatingObject.targetImageSize) {
|
||||
floatingObject.currentImageSize = floatingObject.currentImageSize + 1
|
||||
} else {
|
||||
floatingObject.currentImageSize = floatingObject.currentImageSize - 1
|
||||
}
|
||||
}
|
||||
|
||||
// The fontSize also have a target.
|
||||
|
||||
if (Math.abs(floatingObject.currentFontSize - floatingObject.targetFontSize) >= 0.2) {
|
||||
if (floatingObject.currentFontSize < floatingObject.targetFontSize) {
|
||||
floatingObject.currentFontSize = floatingObject.currentFontSize + 0.2
|
||||
} else {
|
||||
floatingObject.currentFontSize = floatingObject.currentFontSize - 0.2
|
||||
}
|
||||
}
|
||||
|
||||
// We let the Floating Object animate the physics loops by itself.
|
||||
|
||||
floatingObject.physics()
|
||||
|
||||
@@ -124,16 +124,41 @@ function newFloatingObject () {
|
||||
}
|
||||
}
|
||||
|
||||
function physics (callBackFunction) {
|
||||
try {
|
||||
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
|
||||
function physics () {
|
||||
thisObjectPhysics()
|
||||
thisObject.underlayingObject.physics()
|
||||
}
|
||||
|
||||
thisObject.underlayingObject.physics()
|
||||
function thisObjectPhysics () {
|
||||
// The radius also have a target.
|
||||
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) }
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] physics -> err= ' + err.stack) }
|
||||
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) }
|
||||
if (Math.abs(thisObject.container.frame.radius - thisObject.targetRadius) >= 1) {
|
||||
if (thisObject.container.frame.radius < thisObject.targetRadius) {
|
||||
thisObject.container.frame.radius = thisObject.container.frame.radius + 0.5
|
||||
} else {
|
||||
thisObject.container.frame.radius = thisObject.container.frame.radius - 0.5
|
||||
}
|
||||
thisObject.container.eventHandler.raiseEvent('Dimmensions Changed', event)
|
||||
}
|
||||
|
||||
// The imageSize also have a target.
|
||||
|
||||
if (Math.abs(thisObject.currentImageSize - thisObject.targetImageSize) >= 1) {
|
||||
if (thisObject.currentImageSize < thisObject.targetImageSize) {
|
||||
thisObject.currentImageSize = thisObject.currentImageSize + 1
|
||||
} else {
|
||||
thisObject.currentImageSize = thisObject.currentImageSize - 1
|
||||
}
|
||||
}
|
||||
|
||||
// The fontSize also have a target.
|
||||
|
||||
if (Math.abs(thisObject.currentFontSize - thisObject.targetFontSize) >= 0.2) {
|
||||
if (thisObject.currentFontSize < thisObject.targetFontSize) {
|
||||
thisObject.currentFontSize = thisObject.currentFontSize + 0.2
|
||||
} else {
|
||||
thisObject.currentFontSize = thisObject.currentFontSize - 0.2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -240,6 +240,7 @@ function newStrategyPart () {
|
||||
|
||||
thisObject.menu = newCircularMenu()
|
||||
thisObject.menu.initialize(menuItemsInitialValues)
|
||||
thisObject.menu.container.connectToParent(thisObject.container, false, false, true)
|
||||
|
||||
/* Load Part Image */
|
||||
|
||||
|
||||
Reference in new issue
Block a user